2010-07-30 76 views
0

下面的代碼:日期::神祕的iCal(小時不返回正確的值

$ical = Date::ICal->new(year => 1964, month => 10, day => 16, 
          hour => 20, min => 12, sec => 47, 
          #tz => '0530' 
         ); 

ok(defined $ical,   'new() returned something'); 
ok($ical->isa('Date::ICal'), " and it's the right class"); 

is($ical->sec,  47,  ' sec()' ); 
is($ical->min,  12,  ' min()' );  
is($ical->hour, 20,  ' hour()' ); 
is($ical->day,  16,  ' day()' ); 
is($ical->month, 10,  ' month()'); 
is($ical->year, 1964,  ' year()' ); 

print "hour = " . $ical->hour . "\n"; 

和這裏的輸出:

1..8 
ok 1 - new() returned something 
ok 2 - and it's the right class 
ok 3 - sec() 
ok 4 - min() 
not ok 5 - hour() 
# Failed test ' hour()' 
# at ./test_more.pl line 17. 
#   got: '0' 
#  expected: '20' 
not ok 6 - day() 
# Failed test ' day()' 
# at ./test_more.pl line 18. 
#   got: '17' 
#  expected: '16' 
ok 7 - month() 
ok 8 - year() 
hour = 0 
# Looks like you failed 2 tests of 8. 

什麼給????

回答

1

是它是一個時區問題?你是否恰好落後UTC 4小時?

+0

我實際上是5個小時的落後,但是如果沒有指定,我不應該在我的tz中獲得小時數嗎?(這就是爲什麼註釋掉了tz屬性) – ennuikiller 2010-07-30 23:29:27

+0

自10/16/1964起UTC時間4小時後? – mob 2010-07-30 23:34:03

+0

好問題,是的,其實我猜我是...... – ennuikiller 2010-07-30 23:35:27