C+ C NAME: C Time2HMS C PURPOSE: C Convert fraction of day for 2-element standard time C to hour,minute,second,smallest time unit. (Note that this is NOT C the hms since the start of day) C CATEGORY: C gen/for/lib C CALLING SEQUENCE: subroutine Time2HMS(id,t,hms) C INPUTS: C id integer 0 converts time to hms C 1 converts hms to time C t(2) integer id=0: times relative to current origin C hms(4) integer id=1: hms(1): hour C hms(2): minute C hms(3): second C hms(4): fraction of second C (currently millisecond) C OUTPUTS: C t(2) integer id=1: times relative to current origin C hms(4) integer id=0: hms(1): hour C hms(2): minute C hms(3): second C hms(4): fraction of second C (currently millisecond) C CALLS: C Time2Units, Time2Standardize, Time1to2 C SEE ALSO: C Time2DHMS C PROCEDURE: C id=0: time --> hms C Time t is processed first by Time2Standardize. Then t(2) (the remaining C fraction of the day) is converted to hr, min, sec, frac. seconds. C If the input time is standardized already then t(1) is not changed or used. C C id=1: hms --> time C hms is converted to the current fractional units, effectively turning it C into a 1-element standard time. It is then converted to a 2-element C time using Time1to2. If hms represents a positive fraction of a day C (less then one) then t(1) will be zero. C MODIFICATION HISTORY: C JAN-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu) C- integer id integer t(2) integer hms(4) integer Time2Units integer units_in_hour integer units_in_minute integer units_in_second units_in_hour = Time2Units()/24 ! At least 1 units_in_minute = units_in_hour/60 ! Zero if units ar hours units_in_second = units_in_minute/60 ! Zero if units are minutes or hours if (id .eq. 0) then call Time2Standardize(t,t) m = t(2) hms(1) = m/units_in_hour m = m-hms(1)*units_in_hour if (units_in_minute .eq. 0) then hms(2) = 0 hms(3) = 0 hms(4) = 0 else hms(2) = m/units_in_minute m = m-hms(2)*units_in_minute if (units_in_second .eq. 0) then hms(3) = 0 hms(4) = 0 else hms(3) = m/units_in_second hms(4) = m-hms(3)*units_in_second end if end if else call Time1to2(hms(1)*units_in_hour+hms(2)*units_in_minute+hms(3)*units_in_second+hms(4),t) end if return end