Skip to content

vue-i18n / general / ComposerDateTimeFormatting

Interface: ComposerDateTimeFormatting()<DateTimeFormats, Locales, DefinedDateTimeFormat, C, M, ResourceKeys>

Vue I18n Composition

Datetime formatting functions

Remarks

This is the interface for Composer

Type Parameters

Type ParameterDefault type
DateTimeFormats extends Record<string, any>object
Locales"en-US"
DefinedDateTimeFormat extends RemovedIndexResources<DefineDateTimeFormat>RemovedIndexResources<DefineDateTimeFormat>
CIsEmptyObject<DefinedDateTimeFormat> extends false ? PickupFormatPathKeys<{ [K in keyof DefinedDateTimeFormat]: DefinedDateTimeFormat[K] }> : never
MIsEmptyObject<DateTimeFormats> extends false ? PickupFormatKeys<DateTimeFormats> : never
ResourceKeys extends C | MIsNever<C> extends false ? IsNever<M> extends false ? C | M : C : IsNever<M> extends false ? M : never

Call Signature

ts
ComposerDateTimeFormatting(value): string;

Datetime formatting

Parameters

ParameterTypeDescription
valuestring | number | DateA value, timestamp number or Date instance or ISO 8601 string

Returns

string

Formatted value

Remarks

If this is used in a reactive context, it will re-evaluate once the locale changes.

If UseI18nScope 'local' or Some UseI18nOptions are specified at useI18n, it’s translated in preferentially local scope datetime formats than global scope datetime formats.

If not, then it’s formatted with global scope datetime formats.

See about:

Call Signature

ts
ComposerDateTimeFormatting<Value, Key, OptionsType>(value, keyOrOptions): IsPart<OptionsType> extends true ? DateTimeFormatPart[] : string;

Datetime formatting

Type Parameters

Type ParameterDefault type
Value extends string | number | Datenumber
Key extends stringstring
OptionsType| ResourceKeys | Key | DateTimeOptions<ResourceKeys | Key, Locales>

Parameters

ParameterTypeDescription
valueValueA value, timestamp number or Date instance or ISO 8601 string
keyOrOptionsOptionsTypeA key of datetime formats, or additional options for datetime formatting

Returns

IsPart<OptionsType> extends true ? DateTimeFormatPart[] : string

Formatted value

Remarks

Overloaded d.

In this overloaded d, format in datetime format for a key registered in datetime formats.

Call Signature

ts
ComposerDateTimeFormatting<Value, Key, OptionsType>(
   value, 
   keyOrOptions, 
   locale): IsPart<OptionsType> extends true ? DateTimeFormatPart[] : string;

Datetime formatting

Type Parameters

Type ParameterDefault type
Value extends string | number | Datenumber
Key extends stringstring
OptionsType| ResourceKeys | Key | DateTimeOptions<ResourceKeys | Key, Locales>

Parameters

ParameterTypeDescription
valueValueA value, timestamp number or Date instance or ISO 8601 string
keyOrOptionsOptionsTypeA key of datetime formats, or additional options for datetime formatting
localeLocalesA locale, it will be used over than global scope or local scope.

Returns

IsPart<OptionsType> extends true ? DateTimeFormatPart[] : string

Formatted value

Remarks

Overloaded d.

In this overloaded d, format in datetime format for a key registered in datetime formats at target locale

Released under the MIT License.