| 531 | |
| 532 | /** Days since 1970-01-01 from a civil date. */ |
| 533 | const daysFromCivil = (year: number, month: number, day: number): number => { |
| 534 | const y = month <= 2 ? year - 1 : year |
| 535 | const era = Math.floor(y / 400) |
| 536 | const yoe = y - era * 400 |
| 537 | const mp = month > 2 ? month - 3 : month + 9 |
| 538 | const doy = Math.floor((153 * mp + 2) / 5) + day - 1 |
| 539 | const doe = yoe * 365 + Math.floor(yoe / 4) - Math.floor(yoe / 100) + doy |
| 540 | return era * 146097 + doe - 719468 |
| 541 | } |
| 542 | |
| 543 | const monthLengths = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] |
| 544 | |