develooper Front page | perl.datetime | Postings from July 2017

Re: How to tell (in advance) if a date-time is ambiguous?

Thread Previous | Thread Next
From:
Zefram
Date:
July 11, 2017 13:54
Subject:
Re: How to tell (in advance) if a date-time is ambiguous?
Message ID:
20170711135352.GA15923@fysh.org
Binarus wrote:
>As the documentation tells us, DateTime always chooses the later time
>when calculating with ambiguous times,

This logic is actually in DateTime::TimeZone, where DateTime invokes
it via the ->offset_for_local_datetime method.  The internal logic
is able to walk the sequence of observances, and when it finds a
matching observance it looks ahead to the next one to check specially
for ambiguity.  It returns the later span if there's an ambiguity due
specifically to a change from DST to non-DST; it doesn't have guaranteed
behaviour in any other ambiguity scenario.  DT:TZ doesn't document this
feature, and doesn't offer any other form of ambiguity detection in its
API (though of course it would be possible to add some).

>                                       and if you subtract an hour from
>the later (ambiguous) time, you'll get the same time, but the earlier
>one (provided the clock is turned back by an hour when switching back).

You can't rely on offset changes, even specifically ones for DST, being of
an hour.  Australia/Lord_Howe (Lord Howe Island) does a regular half-hour
DST jump.

-zefram

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About