6
此示例以基準日期爲基準,並增加了7½小時,1天7½小時,2天7½小時等等。爲什麼在8:30加入6天7½小時到午夜?
use Date::Manip;
use DateTime;
use DateTime::Format::DateManip;
Date::Manip::Date_Init("TZ=America/New_York", "Language=English");
my $otime = DateTime->new(
year => 2013,
month => 3,
day => 4,
hour => 0,
minute => 0,
second => 0,
time_zone => 'America/New_York',
);
my $t1 = UnixDate($otime, "%i:%M %p on %A, %B %e, %Y ");
print "original $t1\n";
for (my $i = 0; $i <= 20; $i++) {
my $dtw = $otime->clone();
$dtw->add(
minutes => (15) * 30,
days => ($i),
);
$t1 = UnixDate($dtw, "%i:%M %p on %A, %B %e, %Y ");
print "$i days $t1\n";
}
當添加6天7½小時時,結果包含額外的小時。
original 12:00 AM on Monday, March 04, 2013 0 days 07:30 AM on Monday, March 04, 2013 1 days 07:30 AM on Tuesday, March 05, 2013 2 days 07:30 AM on Wednesday, March 06, 2013 3 days 07:30 AM on Thursday, March 07, 2013 4 days 07:30 AM on Friday, March 08, 2013 5 days 07:30 AM on Saturday, March 09, 2013 6 days 08:30 AM on Sunday, March 10, 2013 # why 8:30 and not 7:30? 7 days 07:30 AM on Monday, March 11, 2013 8 days 07:30 AM on Tuesday, March 12, 2013 9 days 07:30 AM on Wednesday, March 13, 2013 10 days 07:30 AM on Thursday, March 14, 2013 11 days 07:30 AM on Friday, March 15, 2013 12 days 07:30 AM on Saturday, March 16, 2013 13 days 07:30 AM on Sunday, March 17, 2013 14 days 07:30 AM on Monday, March 18, 2013 15 days 07:30 AM on Tuesday, March 19, 2013 16 days 07:30 AM on Wednesday, March 20, 2013 17 days 07:30 AM on Thursday, March 21, 2013 18 days 07:30 AM on Friday, March 22, 2013 19 days 07:30 AM on Saturday, March 23, 2013 20 days 07:30 AM on Sunday, March 24, 2013
夏令時? – TLP 2013-03-05 08:11:09
如果您想忽略DST更改,請將時區切換爲「浮動」。 – ikegami 2017-08-08 17:01:38