in reply to Date::Calc and and daylight savings time

Try using Gmtime not Localtime ... at least on my machine it goes from 05:13:27 to 12:13:27, much closer to 13:13:27
while( my( $epoch, $wanted ) = each %date_pairs ){ use Time::Piece qw/ localtime gmtime /; use Date::Language; my $tp = gmtime( $epoch ); $tp = $tp->add_years( 31 ); my $lang = Date::Language->new('German'); my $got = $lang->strftime("%A, %d.%m.%Y - %H:%M:%S", $tp ); print "$got\n$wanted\n\n"; }

Replies are listed 'Best First'.
Re^2: Date::Calc and and daylight savings time
by marek1703 (Acolyte) on Jan 01, 2015 at 11:30 UTC

    Thank you! That's an interesting approach. I never used this module: Time::Piece

    Only Problem: on my Macintosh with 5.18.2 (Built in for MacOS 10.10.1) I get totally wrong results:

    Sonntag, 02.02.2014 - 10:11:49 Sonntag, 02.02.2014 - 11:11:49 Montag, 27.01.2014 - 15:17:20 Montag, 27.01.2014 - 16:17:20 Samstag, 27.09.2014 - 07:09:20 Samstag, 27.09.2014 - 09:09:20 Sonntag, 16.02.2014 - 11:12:50 Sonntag, 16.02.2014 - 12:12:50 Mittwoch, 08.01.2014 - 16:28:38 Mittwoch, 08.01.2014 - 17:28:38 Sonntag, 29.12.2013 - 09:04:19 Sonntag, 29.12.2013 - 10:04:19 Sonntag, 26.05.2013 - 12:13:27 Sonntag, 26.05.2013 - 13:13:27

      It seems two things that you're missing - you need to adjust for the Germany/Berlin timezone (GMT+1), and you also (still) need to figure out when DST is active (which accounts for the two hours difference in September).

      I think DateTime comes with the Olson database embedded, but maybe there are less heavyweight approaches to correcting the timestamp for DST.