0.3.0 • Published 2 years ago

spacetime-holiday v0.3.0

Weekly downloads
229
License
-
Repository
github
Last release
2 years ago

Some holidays are the same day every year, some holidays change astronomically, some by calendar rules like 'third thursday in June'.

This library tries its best to reconcile them.

if it finds a date, it returns a spacetime object.

to conserve filesize of your build, spacetime is a peerDependency, so must be installed separately:

npm i spacetime

npm i spacetime-holiday

const spacetimeHoliday = require('spacetime-holiday')

let s = spacetimeHoliday('easter monday', 2020)
s.format('iso-short')
// 2020-04-12

spacetimeHoliday('groundhog day').format('day') // defaults to next instance
// 'Saturday'

spacetimeHoliday('fall equinox', 2030).format('nice-year')
// 'Sept 22nd, 2030'

// add a timezone
let s = spacetimeHoliday('ramadan', 2019, 'Canada/Pacific')
s.iso()
// 2019-05-05T00:00:00.000-07:00

work-in-progress!

  • american/western holidays 👍

  • Easter-based christian holidays 👍

  • Astronomical holidays 👍

  • Muslim holidays (predicted) 😞

  • Jewish-calendar holidays (not implemented) 😞

  • Chinese-calendar holidays (not implemented) 😞

See also

MIT

0.3.0

2 years ago

0.2.2

2 years ago

0.2.0

2 years ago

0.1.0

3 years ago

0.0.2

4 years ago

0.0.1

4 years ago