View Raw SPL
/****************************************************************************
* *
* UNIXDT.SPL Copyright 2024 (C) DSP Development Corporation *
* *
* Author: Randy Race *
* *
* Synopsis: Converts UNIX seconds to Julian date and seconds *
* *
* Revisions: 2 Nov 2024 RRR Creation *
* *
****************************************************************************/
#if @HELP_UNIXDT
UNIXDT
Purpose: Converts UNIX timestamp to Julian date and clock seconds.
Syntax: UNIXDT(ut, offset, startdate)
(d, t) = UNIXDT(ut, offset, startdate)
ut - A series of UNIX format time stamps.
offset - Optional. A real, the time offset in seconds.
Defaults to 0.0.
startdate - Optional. A string, the starting date. Defaults
to "1-1-1970".
Returns: A two column series of dates and clock time.
(d, t) = unixdt(ut) returns the dates and clock
time in two separate variables.
Example:
W1: {1407159000, 1408159082, 1411150163, 1417159180, 1427159240}
W2: unixdt(W1)
W2 contains the date and time values:
8-04-2014 13:30:00
8-16-2014 3:18:02
9-19-2014 18:09:23
11-28-2014 7:19:40
3-24-2015 1:07:20
Example:
W3: {1407159000, 1408159082, 1411150163, 1417159180, 1427159240}
W4: (d, t) = unixdt(W3); ravel(d, t)
W4 contains the date and time values:
8-04-2014 13:30:00
8-16-2014 3:18:02
9-19-2014 18:09:23
11-28-2014 7:19:40
3-24-2015 1:07:20
Remarks:
UNIX timestamps are generally in seconds elapsed since
1-1-1970. UNIXDT converts the second values into date
and clock time for the day.
See Also:
DT2UNIX
DTXY
JULSTR
STRJUL
STRTOD
TODSTR
XYDT
#endif
/* convert UNIX timestamps to date/time */
unixdt(ut = 0, offset = 0, startdate = "1-1-1970")
{
local jul, secs, dt;
if (outargc > 1)
{
/* use updated function */
(jul, secs) = unix2dt(ut, offset, startdate);
return(jul, secs);
}
else
{
dt = unix2dt(ut, offset, startdate);
return(dt);
}
}