houseabsolute / DateTime-TimeZone

Time zone object base class and factory
https://metacpan.org/release/DateTime-TimeZone/
Other
9 stars 25 forks source link

is_dst function for 'Europe/Dublin' timezone #41

Closed imalikoff closed 4 years ago

imalikoff commented 4 years ago

Hi,

I noticed that 'is_dst' function behaves a bit strange for Dublin timezone. For April it's supposed to return '1', but I got '0', and for March it's 1 (should be 0)

Example (version 2.37 and 2.38): use strict;
use warnings;

use DateTime;
use DateTime::TimeZone;

my $d = DateTime->new(
'year' => 2020,
'month' => 4,
'day' => 3,
'hour' => 3,
'time_zone' => 'Europe/Amsterdam'
);

print $d, "\n";
print "AMSTERDAM IS DST: ", $d->is_dst(), "\n";

my $d1 = DateTime->new(
'year' => 2020,
'month' => 4,
'day' => 3,
'hour' => 3,
'time_zone' => 'Europe/Dublin'
);

print $d1, "\n";
print "DUBLIN IS DST: ", $d1->is_dst(), "\n";

Thanks!

n1vux commented 4 years ago

Interesting and obscure special case!

Dublin rotates between IST and GMT, where I'm presuming IST is Irish Summer Time not Irish Standard Time, but tl;dr in fact, legally since 1968 IST is Standard time in the summer and they observe GMT in the winter as negative savings.

I confirm that the generated data structure in [...Europe::Dublin](https://metacpan.org/source/DROLSKY/DateTime-TimeZone-2.38/lib/DateTime/TimeZone/Europe/Dublin.pm#PDateTime::TimeZone::Europe::Dublin) has GMT from 2019-10-27 01:00Z to 2020-03-29 01:00Z and IST from then to fall. The IS_DST field is 0 for IST and 1 for GMT in the data structure.

This is a strangeness in the Dublin definition in Olson/IANA TZ definitions related to 'format' => 'IST/GMT', rather than 'format' => 'E%sT', . The ordering of the specification IST/GMT in Olson 2019c seems to define Irish Summer/Standard Time (UTC+1) as normal and GMT (UTC0) as the savings.

Alas it is intentional and caused by the legislators, they have negative DST in winter by law; in tz2019c/europe commentary, we read

# From Paul Eggert (2017-12-07):
# The 1996 anonymous contributor's goal was to determine the correct
# abbreviation for summer time in Dublin and so the contributor
# focused on the "IST", not on the "Irish Summer Time".  Though the
# "IST" was correct, the "Irish Summer Time" appears to have been an
# error, as Ireland's Standard Time (Amendment) Act, 1971 states that
# standard time in Ireland remains at UT +01 and is observed in
# summer, and that Greenwich mean time is observed in winter.  (Thanks
# to Derick Rethans for pointing out the error.)  That is, when
# Ireland amended the 1968 act that established UT +01 as Irish
# Standard Time, it left standard time unchanged and established GMT
# as a negative daylight saving time in winter.  So, in this database
# IST stands for Irish Summer Time for timestamps before 1968, and for
# Irish Standard Time after that.  See:
# http://www.irishstatutebook.ie/eli/1971/act/17/enacted/en/print

They do provide, commented out, 3 lines that can be used for non-negative savings.

# Zone  NAME        STDOFF  RULES   FORMAT  [UNTIL]
Zone    Europe/Dublin   -0:25:00 -  LMT 1880 Aug  2
            -0:25:21 -  DMT 1916 May 21  2:00s
            -0:25:21 1:00   IST 1916 Oct  1  2:00s
             0:00   GB-Eire %s  1921 Dec  6 # independence
             0:00   GB-Eire GMT/IST 1940 Feb 25  2:00s
             0:00   1:00    IST 1946 Oct  6  2:00s
             0:00   -   GMT 1947 Mar 16  2:00s
             0:00   1:00    IST 1947 Nov  2  2:00s
             0:00   -   GMT 1948 Apr 18  2:00s
             0:00   GB-Eire GMT/IST 1968 Oct 27
# The next line is for when negative SAVE values are used.
             1:00   Eire    IST/GMT
# These three lines are for when SAVE values are always nonnegative.
#            1:00   -   IST 1971 Oct 31  2:00u
#            0:00   GB-Eire GMT/IST 1996
#            0:00   EU  GMT/IST

The commented out lines correspond better to most peoples understanding of DST but do not conform to the Irish legislative intent. :-(

autarch commented 4 years ago

Thanks for diving into this, @n1vux. As usual, DST is legislative madness.

I'm going to close this issue as it seems that we are doing the right thing here, for a value of "right" that matches the law, not sanity.

imalikoff commented 4 years ago

Thank you for explanation!