spencermountain / spacetime

A lightweight javascript timezone library
http://spacetime.how/
Other
3.98k stars 183 forks source link

Add 'etc/user' timezone #250

Closed Mitsunee closed 3 years ago

Mitsunee commented 3 years ago

This is would useful for converting times back to the user's local timezone.

My current method to do this is having const userTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone at the top of my stuff and hoping it spits out a supported (and correct, looking at you Windows...) timezone.

I ran npm test and got the same output as in the main respository, so I seem to not have caused any new issues :)

spencermountain commented 3 years ago

that is very clever. Lemme play with it on dev, and add some documentation. Thank you!

spencermountain commented 3 years ago

hey @Mitsunee - does this solution work for you?

spacetime().time('4:30pm').goto('Europe/Paris').goto(null).time()
// '4:30pm'

A null input uses the same timezone-guessing logic that a bare spacetime() call does cool?

Mitsunee commented 3 years ago

sounds good to me (: