Check out "Falsehoods programmers believe about time": https://infiniteundo.com/post/25326999628/falsehoods-program...
Check out "Falsehoods programmers believe about time": https://infiniteundo.com/post/25326999628/falsehoods-program...
I just spent 2 days programming a timezone selector in a React form that changes the displayed date/time as you switch timezones but the underlying UTC representation wouldn't change.
All this without loading 500k JS timezone libraries. I only used Intl API and tz.js [1].
The trick simply was to temporarily shift the date by the difference between the local time and the edited time zone. :)
If you're near a change in daylight savings then that will go wrong.
Really this time & timezone stuff should be handled by the OS, system calls or libs should be more sophisticated so we aren't "solving" these problems over and over again.
But I'm about to start ranting about Unicode, so I'll shut up now... ;-)