[SimBot-commits] CVS: simbot/plugins weather.pl,1.104,1.105
Status: Abandoned
Brought to you by:
kstange
|
From: Pete P. <fou...@us...> - 2005-07-26 00:59:29
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18110/plugins Modified Files: weather.pl Log Message: We now make our best guess at the complete timestamp based on the data in the METAR. If a station doesn't update for over a month, it'll be wrong, but hey, so will the weather. Index: weather.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/weather.pl,v retrieving revision 1.104 retrieving revision 1.105 diff -u -d -p -r1.104 -r1.105 --- weather.pl 24 Jul 2005 02:15:56 -0000 1.104 +++ weather.pl 26 Jul 2005 00:58:48 -0000 1.105 @@ -916,11 +916,26 @@ sub parse_metar { } elsif($cur_block =~ m/^(\d{2})(\d{2})(\d{2})Z$/) { # DAY/TIME - $timedate{'day'} = int $1; + my $day = int $1; + $timedate{'day'} = $day; $timedate{'hour'} = int $2; $timedate{'minute'} = int $3; $timedate{'timezone'} = 'UTC'; + if(!defined $timedate{'unixtime'}) { + my ($gmday, $month, $year) = (gmtime())[3, 4, 5]; + if($day > $gmday) { + # the day is after today UTC, so therefore it is probably + # last month. + $month -= 1; + if($month < 0) { + # Month is 0 based (0 = Jan, 11 = Dec) + $month = 11; + $year -= 1; + } + } + $timedate{'unixtime'} = timegm(0, $timedate{'minute'}, $timedate{'hour'}, $day, $month, $year); + } } elsif($cur_block =~ m/^(\d{3}|VRB|GRID\d{3})(\d{2})(?:G(\d{2}))?KT$/) { # WIND # dddss[Ggg]KT |