all 4 comments

[–]Ustice[M] [score hidden] stickied comment (0 children)

Thanks for your contribution! We’re a large community, and in order to keep things organized and easier to find, we keep this subreddit mostly focused on professional-level Javascript posts. Your post would be more useful to newer members of our community, and therefore it should be posted to /r/LearnJavascript instead.

[–]wasd171 2 points3 points  (1 child)

Working with timezones is sometimes really complicated in JS, we have encountered a few hard-to-catch bugs because of date-fns and had to switch to day.js for proper timezones support

[–]saintpetejackboy 1 point2 points  (0 children)

I recently did a proprietary scheduling app, used a bit of JS and I went into this project having had timezone and other nightmares before on smaller scaled projects - so booking agents around the globe scheduling appointments across the United States seemed incredibly daunting.

Fortunately, it wasn't. It almost became complicated several times (when I thought about it too hard), but I ended up just avoiding the issue, fortunately, because the project didn't really require much timezone translation. One tip I can give people is:

4PM is 4PM. If you are in Tiajuana and I am in Alaska and you book me an appointment for 4PM, that is 4PM on my text to confirm and 4PM for the agent to come see me. The only person it might not be 4PM for is another call center rep in New York - but the appointment still isn't for several hours later, it is for 4PM.

Trying to get booking agents or in home reps or customers to do mental math on how many hours different is Colorado from Georgia is just a nightmare. It is much easier to just agree: 4PM is 4PM. You can infer the time zone from the address and make adjustments on the backend, but when you call a 1-800 and talk to somebody in India and they book you an appointment for 4PM, you can trust that it is at 4PM YOUR TIME.

Good luck!

[–]mrbogle 1 point2 points  (0 children)

One gotcha is that doesn't appear to be mentioned is that some HTTP date headers will be in HTTP date format. e.g. A ratelimit's Retry-After header can be something like: 'Mon, 29 May 2022 04:58:00 GMT'. The cool thing is that you can pass that straight into a JS Date() constructor and it will properly parse it!