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

DateTimeFormatContext overview

This module implements a CVDateTimeFormatContext which is used as a mapping between a CVDateTimeFormatPlaceHolder and a CVTemplatePlaceholder. For each CVDateTimeFormatToken, it contains a CVDateTimeFormatPlaceHolder which can format/parse that token. As some tokens are language-dependent, e.g. weekday names, this module provides a constructor from locales, or from translated strings


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: CVWeekDayNames.Type
  readonly longWeekdayNames: CVWeekDayNames.Type
  readonly shortMonthNames: CVMonthNames.Type
  readonly longMonthNames: CVMonthNames.Type
  readonly dayPeriodNames: CVDayPeriodNames.Type
}) => Type

Getters

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, CVDateTimeFormatTokenMap.Type>

Instances

enGB

CVDateTimeFormatContext instance for Great-Britain English language

Signature

export declare const enGB: Type

Models

Type (class)

Type that represents a CVDateTimeFormatContext

Signature

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

make (static method)

Static constructor

Signature

static make(params: MTypes.Data<Type>): Type

[MData.idSymbol] (method)

Returns the id of this

Signature

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

name (property)

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

Signature

readonly name: string

tokenMap (property)

TokenMap of this CVDateTimeFormatContext

Signature

readonly tokenMap: CVDateTimeFormatTokenMap.Type

Module markers

moduleTag

Module tag

Signature

export declare const moduleTag: "@parischap/conversions/formatting/DateTimeFormat/DateTimeFormatContext/"