FUNCTION TimeSystem, local2ut, utc=utc, time=time, silent=silent ;+ ; NAME: ; TimeSystem ; PURPOSE: ; Convert system time to UT ; CATEGORY: ; Time ; CALLING SEQUENCE: ; ut = TimeSystem(local2ut) ; INPUTS: ; local2ut scalar; type:integer; default: 0 ; offset between local time and UT ; OPTIONAL INPUT PARAMETERS: ; /utc (this keyword was introduced in IDL 5.4) ; passed to the IDL function systime ; If this keyword is set then systime already ; returns UT. If /utc is used then local2ut should ; be set to zero. ; OUTPUTS: ; ut scalar; type: time structure ; current universal time ; INCLUDE: @compile_opt.pro ; Return to caller ; CALLS: ; InitVar, IsType, TimeSet, TimeGet, TimeOp ; PROCEDURE: ; The system time is retrieved using the IDL systime function, ; and is assumed to set to the local time. ; UT is calculated by adding 'local2ut' hours to the system time. ; Note that this means that local2ut=0 simply returns the system time. ; MODIFICATION HISTORY: ; NOV-1999, Paul Hick (UCSD/CASS) ; JUL-2002, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ; Fixed version problem reported by Dick Altrock. ; Embedded the 'systime' call containing the /utc keyword inside ; a 'call_function' call to avoid compilation problems on ; pre-5.4 versions of IDL. ;- InitVar, silent , 0 InitVar, local2ut, 0 version = float( strmid( !version.release, 0, 3 ) ) ; This function won't compile on versions prior to 5.4 if the systime ; call is not embedded inside call_function (keyword utc is not supported). IF IsType(time, /undefined) THEN BEGIN IF version GT 5.35 THEN $ time = call_function( 'systime', utc=utc ) $ ELSE $ time = systime() ENDIF time = TimeOp(/add, TimeSet(time), TimeSet(hour=local2ut)) IF silent le 0 THEN $ message, /info, TimeGet(time,format='YYYY/MN/DD hh:mm:ss (DOY)') RETURN, time & END