in reply to Determining Daylight Savings Time
Suppose I give you the date '27 October 2002, 2:30', and the timezone is CET. Is that in daylight savings time or not? The answer is that *both* are possible. There will be a 27 October 2002, 2:30 in DST, followed one hour later by a 27 October 2002, 2:30 not in DST.
Of course it's possible that given a date (and time), and the timezone to calculate which date/times have to be DST, which ones cannot be DST, which ones can be both (typically just one hour/year), and which date/time combinations are impossible (typically one hour/year as well). After all, that's what your computer does too when displaying time ;-) But the rules differ from timezone to timezone.
Note that in your particular example, with TZ = MST7MDT, it's easy, as then the timezone name itself indicates daylight savings time is active.
I don't understand your steps to determine DST though. With step 1, you convert the date to epoch seconds - but you already need to know the timezone and whether it's DST or not for that. And why are you in step 3 fiddling with the epoch?
Finally, did you study Time::Local and see how that tackles the problem?
Abigail
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Determining Daylight Savings Time
by Anonymous Monk on Apr 11, 2020 at 02:00 UTC |