* Returns a date formatter that transforms a date into its locale digit representation
( name: DateType, size: number, offset: number = 0, trim = false, negWrap = false, )
| 316 | * Returns a date formatter that transforms a date into its locale digit representation |
| 317 | */ |
| 318 | function dateGetter( |
| 319 | name: DateType, |
| 320 | size: number, |
| 321 | offset: number = 0, |
| 322 | trim = false, |
| 323 | negWrap = false, |
| 324 | ): DateFormatter { |
| 325 | return function (date: Date, locale: string): string { |
| 326 | let part = getDatePart(name, date); |
| 327 | if (offset > 0 || part > -offset) { |
| 328 | part += offset; |
| 329 | } |
| 330 | |
| 331 | if (name === DateType.Hours) { |
| 332 | if (part === 0 && offset === -12) { |
| 333 | part = 12; |
| 334 | } |
| 335 | } else if (name === DateType.FractionalSeconds) { |
| 336 | return formatFractionalSeconds(part, size); |
| 337 | } |
| 338 | |
| 339 | const localeMinus = getLocaleNumberSymbol(locale, NumberSymbol.MinusSign); |
| 340 | return padNumber(part, size, localeMinus, trim, negWrap); |
| 341 | }; |
| 342 | } |
| 343 | |
| 344 | function getDatePart(part: DateType, date: Date): number { |
| 345 | switch (part) { |
no test coverage detected
searching dependent graphs…