Options
All
  • Public
  • Public/Protected
  • All
Menu

Localazes date to a given locale.

Hierarchy

  • DateLocalizer

Index

Constructors

constructor

  • new DateLocalizer(dateString: string, lang?: string): DateLocalizer
  • Creates an instance of date localizer.

    todo

    define in configuration the defaul locale.

    Parameters

    • dateString: string

      the string of the date to localize. The format expected is YYYY | YYYY/MM | YYYY/MM/DD.

    • Default value lang: string = "en"

    Returns DateLocalizer

Properties

Private dateArr

dateArr: Array<string>

The date splitted in an Array

Private dateString

dateString: string

the string of the date to localize. The format expected is YYYY | YYYY/MM | YYYY/MM/DD.

Private format

format: "LL" | "MMMM YYYY"

The formats to use to format the localized date.

Private lang

lang: string

Private localDate

localDate: string

The localized and formatted date.

Methods

Private addDay

  • addDay(): void

Private analyzeDate

  • analyzeDate(): void
  • Analyzes date to determine how many info have been passed (YYYY | YYYY/MM | YYYY/MM/DD). If only the year was passed, the localization can end here as the is no actual formatting to do.

    Returns void

localize

  • localize(): string

Private processCompolex

  • processCompolex(): void
  • Processe situazions in which we also have the month or month and day. It calls setFormat to determine if the final date should have the day or not. After, if the day was not passed, it calls addDay to add the day value as we cannot work on a partial date. This will not be shown as we have already set a formatting that does not show the day if the user passed a date without the day.

    Returns void

Private setFormat

  • setFormat(): void

Private setFullDate

  • setFullDate(): void

Private setLocale

  • setLocale(): void

Private setYearOnly

  • setYearOnly(): void

Private stringToArr

  • stringToArr(): void