Closed Mitsunee closed 3 years ago
that is very clever. Lemme play with it on dev, and add some documentation. Thank you!
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?
sounds good to me (:
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 :)