SEC_TO_DT Function
Converts any number of seconds into date/time values.
Usage
result = SEC_TO_DT(num_of_seconds)
Input Parameters
num_of_seconds—A scalar representing the number of seconds elapsed from the date specified in the system variable !DT_Base.
Returned Value
result—A date/time variable containing the converted values.
Keywords
Base—A string containing a date, such as “3-27-92”. This is the base date from which the number of seconds is calculated. The default value for Base is taken from the system variable !DT_Base.
Date_Fmt—Specifies the format of the base date, if passed into the function. Possible values are 1, 2, 3, 4, or 5, as summarized in
Table 16-1: Date Format.
where the asterisk (*) represents one of the following separators: dash (–), slash (/), comma (,), period (.), or colon (:).
For a description of these formats, see the PV‑WAVE User’s Guide.
Discussion
This function is useful for converting time stamps that count seconds to date/time values. Most time stamps count seconds from an arbitrary base date. For example, the UNIX time stamp counts seconds from January 1, 1970.
Example 1
This example shows how a value of 20 seconds is represented internally inside a date/time variable after it has been converted with SEC_TO_DT. The example uses a base start date of January 1, 1970.
date = SEC_TO_DT(20, Base='1-1-70', Date_Fmt=1)
PRINT, date
; PV-WAVE prints: { 1970 1 1 0 0 20.0000 79367.000 0}
Example 2
Assume you have the following dataset which contains time stamps and associated measurements. The file contains data collected from January 1, 1990 to January 5, 1990. The base date for the clock is January 1, 1970.
6.3119520e+08 113
6.3128160e+08 768
6.3136800e+08 632
6.3145440e+08 227
6.3154080e+08 224
Assume the above file has been read into two variables. The first column is read into a double-precision array called tarray. The second column is read into an array called fluid_level, which indicates the water level of a lake for each specified time period. You can convert the date/time data in Column 1 to date/time data with the SEC_TO_DT function:
dtarray = SEC_TO_DT(tarray, Base='1-1-70')
PRINT, dtarray
; PV-WAVE prints:
; { 1990 1 1 12 0 1.01192e-05 86672.500 0}
; { 1990 1 2 12 0 1.01192e-05 86673.500 0}
; { 1990 1 3 12 0 1.01192e-05 86674.500 0}
; { 1990 1 4 12 0 1.01192e-05 86675.500 0}
; { 1990 1 5 12 0 1.01192e-05 86676.500 0}
Notice the SEC_TO_DT function creates an array containing a date/time structure for each of the seconds values. The Julian day shown for each date/time is automatically adjusted to reflect the system base date of September 14, 1752.
See Also
System Variables:
!DT_BaseFor more information, see the PV‑WAVE User’s Guide.