(hour: number, hourCycle: HourCycle)
| 368 | } |
| 369 | |
| 370 | function toHourCycle(hour: number, hourCycle: HourCycle): [number | null, number] { |
| 371 | let dayPeriod: number | null = hour >= 12 ? 1 : 0; |
| 372 | switch (hourCycle) { |
| 373 | case 'h11': |
| 374 | // Hours are numbered from 0 to 11. Used in Japan. |
| 375 | if (hour >= 12) { |
| 376 | hour -= 12; |
| 377 | } |
| 378 | break; |
| 379 | case 'h12': |
| 380 | // Hours are numbered from 12 (representing 0) to 11. |
| 381 | if (hour === 0) { |
| 382 | hour = 12; |
| 383 | } else if (hour > 12) { |
| 384 | hour -= 12; |
| 385 | } |
| 386 | break; |
| 387 | case 'h23': |
| 388 | // 24 hour time, numbered 0 to 23. |
| 389 | dayPeriod = null; |
| 390 | break; |
| 391 | case 'h24': |
| 392 | // 24 hour time numbered 24 to 23. Unused but supported by Intl.DateTimeFormat. |
| 393 | hour += 1; |
| 394 | dayPeriod = null; |
| 395 | } |
| 396 | |
| 397 | return [dayPeriod, hour]; |
| 398 | } |
| 399 | |
| 400 | function fromHourCycle(hour: number, dayPeriod: number, hourCycle: HourCycle): number { |
| 401 | switch (hourCycle) { |
no outgoing calls
no test coverage detected