useDate

Commons
stable

Injects the configured date adapter instance. Reads the date options provided by createOrigam() (or a parent OrigamDateProvider) and returns a ready-to-use adapter that abstracts all date arithmetic. Throws if called outside an app context where date options are not provided.

API

Signature

Full TypeScript signature sourced from the composable file.

typescript

useDate() must be called inside a component tree where date options have been registered (via createOrigam({ date: { adapter: DateAdapter } }) or a parent OrigamDateProvider). It throws with a clear message if the injection key is missing.

Consumed interfaces

IDateOptions
ILocaleInstance

API

Return values

Properties and methods exposed by the composable return object.

(adapter instance)
The configured DateAdapter instance. Exposes methods for date creation, comparison, formatting, arithmetic (addDays, startOfMonth, endOfMonth, …) and locale-aware calendar generation (getWeekArray).

Usage

Examples

Ready-to-paste usage snippets.

Format today's date

vue

Compute the week array for the current month

vue