Mercurial > hg > egg-tcls
changeset 199:95012f8f687a
Another round of timestamp parsing changes, urgh.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 16 Jun 2014 03:18:54 +0300 |
parents | 60a4c69c7f25 |
children | bfa9bbcad2e5 |
files | fetch_weather.pl |
diffstat | 1 files changed, 5 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- 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); } }