#! /usr/bin/perl # I am trying to convert the seconds of the sms database into a # reasonable date. # But there is a problem left: the daylight saving time (Sommerzeit vs Winterzeit) use warnings; use strict; use Date::Calc qw(Localtime Day_of_Week Day_of_Week_to_Text); my %date_pairs = ( 391263207 => "Sonntag, 26.05.2013 - 13:13:27", 410000659 => "Sonntag, 29.12.2013 - 10:04:19", 410891318 => "Mittwoch, 08.01.2014 - 17:28:38", 412528640 => "Montag, 27.01.2014 - 16:17:20", 413028709 => "Sonntag, 02.02.2014 - 11:11:49", 414241970 => "Sonntag, 16.02.2014 - 12:12:50", 433494560 => "Samstag, 27.09.2014 - 09:09:20" ); foreach my $key ( keys %date_pairs ) { print "="x130; my $timestamp = $key; my ($year,$month,$day, $hour,$min,$sec, $doy,$dow,$dst) = Localtime($timestamp); print "\nOriginal Vars:\nTimestamp is: $timestamp\nYear: $year, Month: $month, Day: $day, Hour: $hour, Minutes: $min, Seconds: $sec, Day of Year: $doy, Day of Week: $dow, Daylight saving: $dst \n","_"x130,"\n"; $year += 31; $dow = Day_of_Week($year,$month,$day); my $lang = 3; # this is for German language my $dow_name = Day_of_Week_to_Text($dow,$lang); my $calculated_date = sprintf "%s, %02s.%02s.%d - %02s:%02s:%02s", $dow_name, $day, $month, $year, $hour, $min, $sec; print "Transformed Vars:\nYear: $year, Month: $month, Day: $day, Hour: $hour, Minutes: $min, Seconds: $sec, Day of Year: $doy, Day of Week: $dow, Daylight saving: $dst \nCalculated Date:\t$calculated_date\nExpected Date:\t\t$date_pairs{$key}\n"; } print "="x130;