DateTimeContext.ts overview
This module implements a MDateTimeContext which provides, for each MDateTimeFormat.Token, the MTemplatePlaceholder that can format/parse it. As some tokens are language-dependent, e.g. weekday names, this module provides a constructor from locales, or from translated strings
Exports Grouped by Category
Constructors
fromLocale
Tries to build a MDateTimeContext from locale locale. Returns a Some if successful. Returns a None otherwise (non-existent or unavailable locale,…),
Signature
declare const fromLocale: (locale: string) => Option.Option<Type>
fromLocaleOrThrow
Same as fromLocale but returns directly a MDateTimeContext or throws in case of an error
Signature
declare const fromLocaleOrThrow: (locale: string) => Type
fromNames
Constructs a MDateTimeContext from translations provided as strings
Signature
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
Getters
name
Returns the name property of self
Signature
declare const name: MTypes.OneArgFunction<Type, string>
tokenMap
Returns the tokenMap property of self
Signature
declare const tokenMap: MTypes.OneArgFunction<Type, TemplatePlaceholders>
Instances
enGB
MDateTimeContext instance for Great-Britain English language
Signature
declare const enGB: Type
Models
DayPeriodNames (interface)
Array of the names of the two periods in a day, e.g. AM or PM
Signature
export interface DayPeriodNames extends Readonly<Types.TupleOf<2, string>> {}
MonthNames (interface)
Array of the names of the twelve months of a year
Signature
export interface MonthNames extends Readonly<Types.TupleOf<12, string>> {}
PartName (type alias)
Name of a part of a MDateTime (see MDateTime.Parts)
Signature
type PartName = keyof MDateTime.Parts
TemplatePlaceholders (interface)
Array of the MTemplatePlaceholder’s that can format/parse each MDateTimeFormat.Token, indexed by that token’s numeric value
Signature
export interface TemplatePlaceholders extends ReadonlyArray<MTemplatePlaceholder.Type<PartName, number>> {}
Type (class)
Type that represents a MDateTimeContext
Signature
declare class Type {
constructor({ name, tokenMap }: MTypes.Data<Type>)
}
[MData.idSymbol] (method)
Returns the id of this
Signature
declare const [MData.idSymbol]: () => string | (() => string)
name (property)
Name : usually the locale this MDateTimeContext was built from. Or a country name
Signature
readonly name: string
tokenMap (property)
TemplatePlaceholders of this MDateTimeContext
Signature
readonly tokenMap: TemplatePlaceholders
WeekDayNames (interface)
Array of the names of the seven days of a week
Signature
export interface WeekDayNames extends Readonly<Types.TupleOf<7, string>> {}
Module markers
moduleTag
Module tag
Signature
declare const moduleTag: "@parischap/effect-lib/DateTimeContext/"