> -----Original Message-----
> From: Bob Showalter [mailto:[EMAIL PROTECTED]
> Sent: 20 November 2004 02:35
> To: 'John Bruin'; 'Perl Beginners List'
> Subject: RE: Date calculations and daylight saving
>
> John Bruin wrote:
> > I have a script that calculates difference between dates
> and it works
> > well. However if the 2 dates straddle our daylight saving times
> > (March, October) then the result is either plus or minus an hour
> > compared to the expected result.
>
> Are you subtracting "dates" or "local time stamps?" In the
> abstract, "dates"
> have no reference to time zones.
>
> Give some examples of what you're trying to do. What is the
> "expected result"?
>
> If you switch from daylight savings time at 2am on Sunday,
> October 31, then the difference between the local times of
> noon on Saturday the 30th and noon on Sunday the 31st is 25
> hours, not 24 hours. If you're expecting it to be
> 24 hours, that's not correct.
>
Yes this is exactly what I am try to do. I am working out how long jobs take
to complete and I need 1 day to equal 24 hrs and a week to equal 168 hrs
regardless of daylight saving change overs. We used to use a spreadsheet for
this calculation and that's what we're trying to duplicate. Technically
inaccurate yes but for our purposes it gives the expected result.
> >
> > I am using date::parse (which uses Time::Local) to convert the date
> > string to seconds and then localtime and strftime to
> convert back to a
> > string.
>
> What are you converting back to a string? The difference
> between the epoch seconds?
>
Yes I convert the string to epoch seconds and calculate the difference
between the 2 dates. Then I add up how much time has been spent on that
particular job and how much time remains to meet the target completion time.
We get penalised if we pass this target completion time so the script
calculates the time and date each job should be finished based on the time
remaining.
> Note that epoch seconds are always in GMT (UTC). In order for
> your parsing routine to convert a string expressed in some
> local time to epoch seconds, it needs to know the offset from
> the local time to GMT, which is a function of the time zone.
>
Is what I am attempting to do feasible? Currently I am looking at Date::Calc
to see if I can do the calculations without offsetting for local time etc.
Thanks
John
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>