[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Computing Time



loeh@my-deja.com wrote:
> 
> Hi,
> I have a couple of measurements and like to calculate the time between
> them. But I am not sure which routine to use.
> I tried the following but the result is confusing
> IDL> diff=JULDAY(3,17,2000,17,30,22)-JULDAY(3,17,2000,15,22,17)
> IDL> print,diff
> 0.088946760
> IDL> CALDAT, diff, Month, Day, Year, Hour, Minute, Second
> IDL> PRINT, Month, Day, Year, Hour, Minute, Second
> 1 1 -4713 14 8
> 5.0000381
> Thanks for help
> Mirko
> 

JULDAY will give you fractional days as an answer. To convert this back
into
days, hours, minutes, etc., you can do:
   days = fix(diff)   ; or long() if you desire
   hour = fix( (diff-days)*24. )
   minute = fix( (diff-days-hour/24.)*1440. )
   second = fix( (diff-days-hour/24.-minute/1440.)*86400. )
just that you may run into roundoff problems here or there. And this is
why you should probably follow Liam's advice and use the JHU APL
routines.

Cheers,
Martin


PS: and to save you from likely headaches: always use DOUBLE if you deal
with time variables (except maybe for storing them in a file)

-- 
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
[[ Dr. Martin Schultz   Max-Planck-Institut fuer Meteorologie    [[
[[                      Bundesstr. 55, 20146 Hamburg             [[
[[                      phone: +49 40 41173-308                  [[
[[                      fax:   +49 40 41173-298                  [[
[[ martin.schultz@dkrz.de                                        [[
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[