parseDateTokens() function

Parse an ICU DateFormat skeleton string into a DateToken array.

Signature:

export declare function parseDateTokens(src: string): DateToken[];

Parameters

Parameter Type Description
src string The skeleton string

Returns:

DateToken[]

Remarks

Errors will not be thrown, but if encountered are included as the relevant token’s error value.

Example

import { parseDateTokens } from '@messageformat/date-skeleton'

parseDateTokens('GrMMMdd', console.error)
// [
//   { char: 'G', field: 'era', desc: 'Era', width: 1 },
//   { char: 'r', field: 'year', desc: 'Related Gregorian year', width: 1 },
//   { char: 'M', field: 'month', desc: 'Month in year', width: 3 },
//   { char: 'd', field: 'day', desc: 'Day in month', width: 2 }
// ]