Subject: | Time/Date bug |
The conversion of the weather.com lsup-date/time is wrong in the current
version of weather::com. The conversion does not correctly interpret the
AM/PM times around midnight which for weather.com follow the standard US
notation (which by no means is logical).
Midnight according to US standards is 12AM of the new day, while noon is
12PM of that day. The hour between midnight and 1AM according to US
standards is counted at 12PM(!) i.e. the clock goes backwards when going
from 12:59AM to 1:00AM.
However the time conversion within weather::com currently gives the
following results, i.e. it assumes that the first hour of the day is
given as 0AM:
lsup '5/29/09 9:20 PM Local Time' -> 2009-05-29 21:20:00 local time
lsup '5/29/09 11:20 PM Local Time' -> 2009-05-29 23:20:00 local time
lsup '5/29/09 11:59 PM Local Time' -> 2009-05-29 23:59:00 local time
lsup '5/29/09 0:20 AM Local Time' -> 2009-05-29 00:20:00 local time
lsup '5/29/09 12:20 AM Local Time' -> 2009-05-29 12:20:00 local time
lsup '5/29/09 12:20 PM Local Time' -> 2009-05-30 00:20:00 local time
see also:
http://en.wikipedia.org/wiki/12-hour_clock
http://www.mathsisfun.com/time.html
Thanks for a great tool!
Uwe.
Subject: | weathercom_timetest.pl |
#!/usr/bin/perl -w
# $Revision: 1.1 $
use DBI;
use Weather::Com;
#===============================================================================
my $lsup = Weather::Com::DateTime->new(2); # CEST
my $date = '5/29/09 9:20 PM Local Time';
$lsup->set_lsup($date);
print sprintf("lsup '%s' -> %s local time\n",$date,$lsup->formatted('yyyy-mm-dd hh:mm{in}:ss'));
$date = '5/29/09 11:20 PM Local Time';
$lsup->set_lsup($date);
print sprintf("lsup '%s' -> %s local time\n",$date,$lsup->formatted('yyyy-mm-dd hh:mm{in}:ss'));
$date = '5/29/09 11:59 PM Local Time';
$lsup->set_lsup($date);
print sprintf("lsup '%s' -> %s local time\n",$date,$lsup->formatted('yyyy-mm-dd hh:mm{in}:ss'));
$date = '5/29/09 0:20 AM Local Time';
$lsup->set_lsup($date);
print sprintf("lsup '%s' -> %s local time\n",$date,$lsup->formatted('yyyy-mm-dd hh:mm{in}:ss'));
$date = '5/29/09 12:20 AM Local Time';
$lsup->set_lsup($date);
print sprintf("lsup '%s' -> %s local time\n",$date,$lsup->formatted('yyyy-mm-dd hh:mm{in}:ss'));
$date = '5/29/09 12:20 PM Local Time';
$lsup->set_lsup($date);
print sprintf("lsup '%s' -> %s local time\n",$date,$lsup->formatted('yyyy-mm-dd hh:mm{in}:ss'));