# HG changeset patch # User Matti Hamalainen # Date 1402877934 -10800 # Node ID 95012f8f687aec4c4c7c2c4a5f081047c6e3d880 # Parent 60a4c69c7f25be5f1a8aa1874930378e7a417e3e Another round of timestamp parsing changes, urgh. diff -r 60a4c69c7f25 -r 95012f8f687a fetch_weather.pl --- a/fetch_weather.pl Mon Jun 16 03:18:38 2014 +0300 +++ b/fetch_weather.pl Mon Jun 16 03:18:54 2014 +0300 @@ -17,8 +17,8 @@ use HTML::Entities; use XML::Simple; use Text::Iconv; -use Time::Piece; use Date::Format; +use Date::Parse; use Data::Dumper; @@ -73,7 +73,7 @@ sub format_time_gmt($) { # 2012-02-27T00:00:00Z - return gmtime($_[0])->strftime("%Y-%m-%dT%TZ"); + return time2str("%Y-%m-%dT%TZ", $_[0], "UTC"); } @@ -369,11 +369,11 @@ # Find our desired element nodes my $odata = fnodea(fnode($otree, "body"), "div", "class=elementc"); my $oupdate = fnode($odata, "p"); - my $time_base = Time::Piece->strptime("00:00", "%H:%M")->epoch; + my $time_base = str2time("00:00"); if ($oupdate) { my $tmp = $oupdate->{"nodes"}[0]{"text"}; - if ($tmp =~ /:\s+(\d\d\.\d\d\.\d\d\d\d)\s+(\d\d:\d\d)/) { - $time_base = Time::Piece->strptime($1." 00:00", "%d.%m.%Y %H:%M")->epoch; + if ($tmp =~ /:\s+(\d\d)\.(\d\d)\.(\d\d\d\d)\s+(\d\d:\d\d)/) { + $time_base = str2time($3."-".$2."-".$1); } }