Welcome to this week's episode of Yet Another Time Zone Question:
I've done a fair bit of reading on SO, tried to manipulate moment.js and date.js into helping me, and generally been plagued by a feeling of frustration since I started trying to solve this, so if someone could help or point me at the duplicate question on SO that I just haven't been able to find, that'd be awesome.
I have a page. This page displays a series of times, e.g.: 7:28, 7:38, 7:48. I know whether these are AM/PM. These times are always America/New York (they do not change when daylight savings time changes, as the event they correspond to always happens at that time regardless of DST). Let's call them a schedule. I want to highlight the time that is coming up next.
- This is trivial for people living in America/New York.
- This is not too terrible for people living in America/Los Angeles (assuming my logic works).
- I can take the current time of the computer in America/Los Angeles, convert it to UTC, then determine if America/Los Angeles is currently observing DST or not and determine whether America/New York should be -0400 or -0500, apply that to the UTC, and make my comparison. This hurts a little because you're still always dealing with a Date based in America/Los Angeles and not actually changing the time zone of the Date object, but I have a reliable means of rolling back (or forward) the hours from the UTC time.
What happens, however, when I try to determine if daylight savings time is being observed from a computer in a region that does not observe daylight savings time at all?
JavaScript will only create Date objects for the current time zone, to my knowledge, and then doing any determination of DST is based on that Date object.
Should I just not care? The times are primarily relevant only to people living in America/New York anyway. I'm just trying to build an application that makes sense when viewed from another time zone such that when it's 3AM in country_without_DST and it's 2PM in America/New York, the 'schedule' highlights that the 2:05PM thing is about to happen and not the 3:05AM thing.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…