MCPcopy Create free account
hub / github.com/Effect-TS/effect / daysFromCivil

Function daysFromCivil

packages/sql/pg/src/PgTypes.ts:533–541  ·  view source on GitHub ↗
(year: number, month: number, day: number)

Source from the content-addressed store, hash-verified

531
532/** Days since 1970-01-01 from a civil date. */
533const 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
543const monthLengths = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
544

Callers 1

parseDateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected