Skip to main content Link Search Menu Expand Document (external link)

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>

Source

fromLocaleOrThrow

Same as fromLocale but returns directly a MDateTimeContext or throws in case of an error

Signature

declare const fromLocaleOrThrow: (locale: string) => Type

Source

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

Source

Getters

name

Returns the name property of self

Signature

declare const name: MTypes.OneArgFunction<Type, string>

Source

tokenMap

Returns the tokenMap property of self

Signature

declare const tokenMap: MTypes.OneArgFunction<Type, TemplatePlaceholders>

Source

Instances

enGB

MDateTimeContext instance for Great-Britain English language

Signature

declare const enGB: Type

Source

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>> {}

Source

MonthNames (interface)

Array of the names of the twelve months of a year

Signature

export interface MonthNames extends Readonly<Types.TupleOf<12, string>> {}

Source

PartName (type alias)

Name of a part of a MDateTime (see MDateTime.Parts)

Signature

type PartName = keyof MDateTime.Parts

Source

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>> {}

Source

Type (class)

Type that represents a MDateTimeContext

Signature

declare class Type {
  constructor({ name, tokenMap }: MTypes.Data<Type>)
}

Source

[MData.idSymbol] (method)

Returns the id of this

Signature

declare const [MData.idSymbol]: () => string | (() => string)

Source

name (property)

Name : usually the locale this MDateTimeContext was built from. Or a country name

Signature

readonly name: string

Source

tokenMap (property)

TemplatePlaceholders of this MDateTimeContext

Signature

readonly tokenMap: TemplatePlaceholders

Source

WeekDayNames (interface)

Array of the names of the seven days of a week

Signature

export interface WeekDayNames extends Readonly<Types.TupleOf<7, string>> {}

Source

Module markers

moduleTag

Module tag

Signature

declare const moduleTag: "@parischap/effect-lib/DateTimeContext/"

Source