npm.io
0.0.1 • Published 5 years ago

spacetime-week-math

Licence
MIT
Version
0.0.1
Deps
0
Size
3 kB
Vulns
0
Weekly
0
Stars
4.1K
calculate the nth day of a month
spacetime-week-math
by Spencer Kelly

a spacetime plugin to calculate the nth day of a month.

like .week() which is based on the year, .monthWeek() works as a getter+setter, based on the input param:


// Oct 2020 starts on a thursday
let s = spacetime('saturday oct 10th 2020')
s.monthWeek()
// 2

s = s.monthWeek(1)
// Mon Sep 28th

the week numbers start at 1.

Note: the getter/setter can produce different results:

let s = spacetime('saturday oct 10th 2020')
s = s.monthWeek(1)
// Mon Sep 28th
s.monthWeek()
// 5

Sep 28th is considered the 5th week of September.

work-in-progress.

MIT