Re: How to Compute Hours In a Day?

2008-10-20 Thread jim . monty
Eugene van der pijll wrote: Jim Monty schreef: I want to iterate the time zones of the world to generate a report of all days that aren't exactly 24 hours. I want to handle America/Caracas and America/Sao_Paulo correctly. You mentioned 2007-12-09 was 24.5 hours long in Venezuela. This is

Re: How to Compute Hours In a Day?

2008-10-20 Thread Eugene van der Pijll
[EMAIL PROTECTED] schreef: Here's my first shot at a script. It combines Zefram's suggestion to use $dt-epoch() and Eugene's recommendation to measure the intervals at noon instead of at midnight. Next, I'd like to refactor it using...um...I'm not sure, but something other than $dt-epoch(). I

Re: How to Compute Hours In a Day?

2008-10-20 Thread Zefram
[EMAIL PROTECTED] wrote:     C:\perl oddhours.pl 2007     2007-12-09  24.5  America/Caracas     2007-03-11  22    America/Indiana/Winamac     2007-03-25  24.5  Australia/Lord_Howe     2007-10-28  23.5  Australia/Lord_Howe Interesting, Australia/Lord_Howe does a half-hour DST shift every year.    

How to Compute Hours In a Day?

2008-10-19 Thread jim . monty
How do I compute the number of hours in a day in a specific time zone?   Let's say I want to iterate the days of the year from Jan 1 thru Dec 31 and print the number of hours in each day in the America/New_York time zone. I expect 363 days to have 24 hours, one day to have 23 hours, and one day to

Re: How to Compute Hours In a Day?

2008-10-19 Thread Zefram
[EMAIL PROTECTED] wrote: How do I compute the number of hours in a day in a specific time zone? Try this: use DateTime; for(my $today = DateTime-new(year=2007, time_zone=$ARGV[0]); $today-year == 2007; ) { (my $tomorrow = $today-clone)-add(days=1); print $today, ,

Re: How to Compute Hours In a Day?

2008-10-19 Thread Eugene van der Pijll
Zefram schreef: It ought to be possible to do the interval calculation using DateTime::Duration instead of -epoch, but the behaviour of DT::D is unreasonably confusing and I couldn't get it to work. (Strangely, I got a version that worked fine for America/New_York, where all the days are

Re: How to Compute Hours In a Day?

2008-10-19 Thread jim . monty
Zefram wrote: [EMAIL PROTECTED] wrote: How do I compute the number of hours in a day in a specific time zone? Try this: Thanks for the working example. It's helpful. It ought to be possible to do the interval calculation using DateTime::Duration instead of -epoch, but the behaviour of

Re: How to Compute Hours In a Day?

2008-10-19 Thread Eugene van der Pijll
[EMAIL PROTECTED] schreef: I want to iterate the time zones of the world to generate a report of all days that aren't exactly 24 hours. I want to handle America/Caracas and America/Sao_Paulo correctly. You mentioned 2007-12-09 was 24.5 hours long in Venezuela. This is precisely the kind of

Re: How to Compute Hours In a Day?

2008-10-19 Thread Dave Rolsky
On Mon, 20 Oct 2008, Eugene van der Pijll wrote: DateTime cannot handle fractional leap hours. See the source code of subtract_datetime(), section This is a gross hack, where the length of the leap hour is hardcoded in the lines $bigger_min -= 60 $bigger_min += 60 This should probably