I think your logic is slightly amiss when you calculate the "start of this day". This variant works for me:
#!/usr/bin/perl -Tw use strict; print "Today: " . hours_in_day (time) . "hours.\n"; print "Sun: " . hours_in_day (time-170000) . "hours.\n"; sub hours_in_day { my $now = 60*60*int( shift()/60/60 ); # Start of this hour my $hour = ( localtime($now) )[2]; $now -= $hour*60*60; # Offset from start of thi +s day $hour = ( localtime($now) )[2]; $hour += 24 unless int($hour/12); return $hour; }
and gives this output for me (Sunday was the switch from BST to GMT here):
Today: 24hours. Sun: 25hours.
In reply to Re^3: Is there an official DST border day detection module? (localtime)
by hippo
in thread Is there an official DST border day detection module?
by flowdy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |