DateTimeFormatContext overview
This module implements a CVDateFormatContext
which is used when parsing or formatting dates (see DateTimeFormat.ts) to provide the translations used by language specific tokens (e.g. MMMM
)
Table of contents
Constructors
fromLocale
Tries to build a CVDateTimeFormatContext
from locale locale
. Returns a Some
if successful. Returns a None
otherwise (non-existent or unavailable locale,…),
Signature
export declare const fromLocale: (locale: string) => Option.Option<Type>
fromLocaleOrThrow
Same as fromLocale
but returns directly a CVDateTimeFormatContext
or throws in case of an error
Signature
export declare const fromLocaleOrThrow: (locale: string) => Type
fromNames
Constructs a CVDateTimeFormatContext
from translations provided as strings
Signature
export declare const fromNames: ({
name,
shortWeekdayNames,
longWeekdayNames,
shortMonthNames,
longMonthNames,
dayPeriodNames
}: {
readonly name: string
readonly shortWeekdayNames: WeekDayNames
readonly longWeekdayNames: WeekDayNames
readonly shortMonthNames: MonthNames
readonly longMonthNames: MonthNames
readonly dayPeriodNames: DayPeriodNames
}) => Type
Destructors
name
Returns the name
property of self
Signature
export declare const name: MTypes.OneArgFunction<Type, string>
tokenMap
Returns the tokenMap
property of self
Signature
export declare const tokenMap: MTypes.OneArgFunction<Type, TokenMap.Type>
Guards
has
Type guard
Signature
export declare const has: (u: unknown) => u is Type
Instances
enGB
CVDateTimeFormatContext
instance for Great-Britain English language
Signature
export declare const enGB: Type
Model
Type (interface)
Type that represents a CVDateTimeFormatContext
Signature
export interface Type extends MInspectable.Type, Pipeable.Pipeable {
/** Name : usually the locale this `CVDateTimeFormatContext` was built from. Or a country name */
readonly name: string
/** TokenMap of this `CVDateTimeFormatContext` */
readonly tokenMap: TokenMap.Type
/** @internal */
readonly [_TypeId]: _TypeId
}
Models
DayPeriodNames (type alias)
Type that represents the names of the day periods, e.g. AM or PM
Signature
export type DayPeriodNames = MTypes.Tuple<string, 2>
MonthNames (type alias)
Type that represents the names of the twelve months of a year
Signature
export type MonthNames = MTypes.Tuple<string, 12>
Token (type alias)
Type that represents all the possible tokens that can be used to format a CVDateTime
Signature
export type Token =
/* Gregorian year (ex: 2005) */
| "y"
/* Gregorian year on 2 digits left-padded with 0's corresponding to years 2000-2099 (ex: 05 for 2005) */
| "yy"
/* Gregorian year on 4 digits left-padded with 0's (ex: 2005, 0965) */
| "yyyy"
/* Iso year (ex: 2005) */
| "R"
/* Iso year on 2 digits left-padded with 0's corresponding to years 2000-2099 (ex: 05 for 2005) */
| "RR"
/* Iso year on 4 digits left-padded with 0's (ex: 2005, 0965)*/
| "RRRR"
/* Month (ex: 6) */
| "M"
/* Month on 2 digits left-padded with 0's (ex: 06) */
| "MM"
/* Short month name (ex: Jun) */
| "MMM"
/* Long month name (ex: June) */
| "MMMM"
/* IsoWeek (ex: 6) */
| "I"
/* IsoWeek (ex: 06) */
| "II"
/* Day of month (ex: 5) */
| "d"
/* Day of month on 2 digits left-padded with 0's (ex: 05) */
| "dd"
/* Day of year (ex: 97) */
| "D"
/* Day of year on 3 digits left-padded with 0's (ex: 097) */
| "DDD"
/* Weekday (ex: 1 for monday, 7 for sunday) */
| "i"
/* Short weekday name (ex: Mon) */
| "iii"
/* Long weekday name (ex: Monday) */
| "iiii"
/* Meridiem (ex: 'AM' for 0, 'PM' for 12) */
| "a"
/* Hour in the range 0..23 (ex:5, 14) */
| "H"
/* Hour on 2 digits in the range 0..23 left-padded with 0's (ex:05, 14) */
| "HH"
/* Hour in the range 0..11 (ex:5, 2) */
| "K"
/* Hour on 2 digits in the range 0..11 left-padded with 0's (ex:05, 02) */
| "KK"
/* Minute (ex: 5) */
| "m"
/* Minute on 2 digits left-padded with 0's (ex: 05) */
| "mm"
/* Second (ex: 5) */
| "s"
/* Second on 2 digits left-padded with 0's (ex: 05) */
| "ss"
/* Millisecond (ex: 5) */
| "S"
/* Millisecond on 3 digits left-padded with 0's (ex: 005) */
| "SSS"
/* Hour part of the timezone offset (ex: 5) */
| "zH"
/* Hour part of the timezone offset on 2 digits left-padded with 0's (ex: 05) */
| "zHzH"
/* Minute part of the timezone offset (ex: 5) */
| "zm"
/* Minute part of the timezone offset on 2 digits left-padded with 0's (ex: 05) */
| "zmzm"
/* Second part of the timezone offset (ex: 5) */
| "zs"
/* Second part of the timezone offset on 2 digits left-padded with 0's (ex: 05) */
| "zszs"
WeekDayNames (type alias)
Type that represents the names of the seven days of a week
Signature
export type WeekDayNames = MTypes.Tuple<string, 7>
Module markers
moduleTag
Module tag
Signature
export declare const moduleTag: "@parischap/conversions/DateTimeFormatTemplate/"