pro TimeOrigin, t0, units_in_day=units_in_day, $ time=time, d2000=d2000, jd=jd, mjd=mjd, njd=njd, $ get=get ;+ ; NAME: ; TimeOrigin ; PURPOSE: ; Converts time structure to array and v.v. ; CATEGORY: ; gen/idl/toolbox/time ; CALLING SEQUENCE: ; u = TimeOrigin(t) ; INPUTS: ; t0 /get NOT set: ; array[1]; type: time structure ; time origin additional offset to the origin ; defined in keywords /d2000, /jd, /mjd, /njd ; OPTIONAL INPUT PARAMETERS: ; /get if set then the current settings are returned in t0 ; /time do not change the origin, only change time units ; /d2000 if set then the origin is set to 2000 Jan 1, 0 UT ; (plus t0 if specified). ; /jd if set then the origin is set to JD=0 ; (plus t0 if specified) ; /mjd if set then the origin is set to JD=2400000 ; (plus t0 if specified) ; /njd if set then the origin is set to 2000 Jan 1, 12 UT ; (plus t0 if specified) ; units_in_day=units_in_day ; scalar; type: integer; default: !TimeUnits.in_day ; # times per day ; OUTPUTS: ; u array; type: array[2,*] or time structure ; converted time ; OPTIONAL OUTPUT PARAMETERS: ; t0 /get SET: current settings of time origin and time units ; INCLUDE: @compile_opt.pro ; On error, return to caller ; CALLS: ; InitVar, TimeArray, TimeOp, IsType ; PROCEDURE: ; Uses structure definition in !TheTime ; MODIFICATION HISTORY: ; JAN-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ;- InitVar, get , /key InitVar, time , /key InitVar, d2000, /key InitVar, jd , /key InitVar, mjd , /key InitVar, njd , /key InitVar, units_in_day, !TimeUnits.in_day case 1 of d2000: begin t = TimeArray([ 0L, 0L]) u = 86400000L end jd : begin t = TimeArray([-2451545L, 43200000L]) u = 86400000L end mjd : begin t = TimeArray([ -51545L, 43200000L]) u = 86400000L end njd : begin t = TimeArray([ 0L, 43200000L]) u = 86400000L end time : begin t = !TimeZero u = !TimeUnits.in_day end endcase t = TimeOp(/units, t, old_units=u, new_units=units_in_day) case get of 0: begin !TimeZero = t !TimeUnits.in_day = units_in_day if IsType(t0,/defined) then !TimeZero = TimeOp(/add, !TimeZero,TimeArray(t0)) end 1: t0 = t endcase return & end