(datetime: Date)
| 519 | * ISO Week starts on day 1 (Monday) and ends with day 0 (Sunday) |
| 520 | */ |
| 521 | export function getThursdayThisIsoWeek(datetime: Date) { |
| 522 | // getDay returns 0-6 range with sunday as 0. |
| 523 | const currentDay = datetime.getDay(); |
| 524 | |
| 525 | // On a Sunday, read the previous Thursday since ISO weeks start on Monday. |
| 526 | const deltaToThursday = currentDay === 0 ? -3 : THURSDAY - currentDay; |
| 527 | |
| 528 | return createDate( |
| 529 | datetime.getFullYear(), |
| 530 | datetime.getMonth(), |
| 531 | datetime.getDate() + deltaToThursday, |
| 532 | ); |
| 533 | } |
| 534 | |
| 535 | function weekGetter(size: number, monthBased = false): DateFormatter { |
| 536 | return function (date: Date, locale: string) { |
no test coverage detected