@heinlein-video/rrule
Version:
rrule fork. Includes the src/ folder for typescript sourceMaps
21 lines (19 loc) • 712 B
text/typescript
export function easter(y: number, offset = 0) {
const a = y % 19
const b = Math.floor(y / 100)
const c = y % 100
const d = Math.floor(b / 4)
const e = b % 4
const f = Math.floor((b + 8) / 25)
const g = Math.floor((b - f + 1) / 3)
const h = Math.floor(19 * a + b - d - g + 15) % 30
const i = Math.floor(c / 4)
const k = c % 4
const l = Math.floor(32 + 2 * e + 2 * i - h - k) % 7
const m = Math.floor((a + 11 * h + 22 * l) / 451)
const month = Math.floor((h + l - 7 * m + 114) / 31)
const day = ((h + l - 7 * m + 114) % 31) + 1
const date = Date.UTC(y, month - 1, day + offset)
const yearStart = Date.UTC(y, 0, 1)
return [Math.ceil((date - yearStart) / (1000 * 60 * 60 * 24))]
}