;+ ; NAME: ; TimeDay ; PURPOSE: ; Converts numerical day value to time structure and v.v ; CATEGORY: ; gen/idl/toolbox/time ; CALLING SEQUENCE: FUNCTION TimeDay, t ; INPUTS: ; t array; type: time structure or any numerical type ; OUTPUTS: ; Result array; type: nummerical or time structure ; INCLUDE: @compile_opt.pro ; On error, return to caller ; CALLS: ; IsTime, TimeStandardize, TimePieces ; RESTRICTIONS: ; This function is for use in TimeGet and TimeSet only. ; Other code should make calls to TimeGet or TimeSet: ; u = TimeSet(day=t,/diff) ; u = TimeGet(day=t,/diff) ; SIDE EFFECTS: ; Accesses !TimeUnits.in_day ; PROCEDURE: ; > If the input is a type structure than is an integer array ; if all the fractions of a day are zero, or else a double array ; is returned ; > If the input is a numerical array then it is converted to ; a time structure with the integer part as the number of days, ; and the fraction as time of day. ; MODIFICATION HISTORY: ; JAN-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ;- CASE IsTime(t) OF 0: BEGIN u = !TheTime IF size(t,/n_dim) GT 0 THEN u = replicate(u, (size(t,/dim))) d = floor(t) u = TimePieces(/days, u, d) u = TimePieces(/unit, u, round( (t-d)*!TimeUnits.in_day ) ) u = TimeStandardize(u) END 1: BEGIN u = TimePieces(/days,t) d = TimePieces(/unit,t) IF (where(d NE 0))[0] NE -1 then u = u+double(d)/!TimeUnits.in_day END ENDCASE RETURN, u & END