github
Yeah, 🙌
the world's really big
but this library, it's really small ✨
{{timezone}}:
{{s.format('month')+' '+s.format('ordinal')}}
{{s.time()}}
â–ŧ
6am
noon
6pm
10pm
january
march
may
july
september
november
 
{{s.season()}}
dst
leap-year
Q{{s.quarter()}}
{{s.dayTime()}}
īšŖ {{c.render()}} +
⇤ {{c.title}} â‡Ĩ
— spacetime date-utility —
đŸ’Ĩ - local model of remote TZ
đŸ’Ĩ - DST, leap-year, hemisphere!
đŸ’Ĩ - moment-like💙 API
đŸ’Ĩ - quarter, season, and week-orientation
33 kb
that's more like it
npm install spacetime
or
<script src='https://unpkg.com/spacetime'></script>
👹 spacetime does some ugly things.
it can sometimes get confused. 🌌
but by making realistic compromises spacetime considerably under-weighs most date libraries.
It lets you have a mostly-great time, without thinking about awful things.
now go crazy:
how the?
it is currently {{epoch}} everywhere (even in Australia).
[Fake-Paris]
time
= Epoch time
({{epoch}})
īšŖ your computer's offset
({{offset}} mins)
+ current offset
Europe/Paris
(with DST)
that's not too bad.

but hold up -

to change the date, you have to shift to your computer's offset, make the calendar-based change, then shift it back to Paris time, in some kind of distopian web programming:
this is error-prone!

one challenge is that different DST rules may apply on your computer, compared to Paris-time.
- you may miss a DST-shift while pretending to be in Paris, but lying about it.
another possibility is making a very specific time locally, that doesn't exist in Paris-time.
spacetime 🎉 (mostly) addresses these problems in post-processing the date after every transformation, to ensure the funny-business is a minimum.

if it's 9:37pm, and you move forward 6 months, it should still be 9:37pm.
- even the day of the month should remain stable too, when possible

There is admittedly, some guesswork involved.
but what a pleasure, to let this little library do that for you 🌈

not for every use-case, fine for most. -
API:
{{doc.title}}(): {{doc.doc}} returns: {{doc.out}}
main:
{{k}}()
getters/setters
{{k}}()
utils:
{{k}}()

Apache-2.0
- by SmallWins