On 1/15/2014 3:39 PM, Jeremy Nicoll - news posts wrote:
> Arthur T. <art...@munged.invalid> wrote:
>
>> I'd like to compute the time difference between two time/date
>> stamps. The inputs will be in the format of yyyymmdd hh:mm:ss.
>>
>> Is there anything easier than computing the number of days
>> difference, converting to seconds, then adding the time difference,
>> and adjusting for partial days (e.g. if end-time is less than
>> start-time, subtract one day)?
>
> I'd probably do it slightly differently by expressing each date & time as a
> number of whole & fractional days, essentially adding
>
> (hh*3600 + mm*60 + ss)/86400
>
> to each day's base date, to get values that are easily subtracted.
>
> This doesn't take account of problems like clock changes twice per year.
>
That's the approach I took when comparing the date/time of a file in a
zip archive with that of the file on disk. But I used the ooRexx 'Full'
option. which returns the number of microseconds since 00:00:00.000000
on 1 Jan 0001. That feature makes it fairly simple:
Numeric Digits 18 -- needed To add the timestamps
filestamp = Date('f', dt,'S','','-') + Time('f',tm, 'N')
zipstamp = Date('f', zdt,'S','','-') + Time('f',ztm, 'N')
timediff=(zipstamp-filestamp)/1000000
From there, it's straightforward to deal with DST and convert to
convenient display units.