Description
Convert scalar year, month, day, hour, minute, and second fields to epoch time,
or decompose epoch time into calendar fields. Select the conversion direction
with the program's mode parameter; input fields must use the expected units.
Synopsis
sgtime mode=encode jan=1 DST=0 <stdin in.year=FIELD("year") in.month=FIELD("month") in.day=FIELD("day") in.hour=FIELD("hour") in.min=FIELD("min") in.sec=FIELD("sec") in.epoch=FIELD("epoch") >stdout out.epoch="epoch" out.year="year" out.month="month" out.day="day" out.hour="hour" out.min="min" out.sec="sec"
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
mode |
enum |
encode
|
operation mode: encode: convert (year,month,mday,hour,min,sec) to Epoch time decode: convert Epoch time to (year,month,mday,hour,min,sec) |
jan |
int |
1
|
January as 0 or 1 |
DST |
int |
0
|
Day Saving Time: 0 no, 1 yes, -1 unknown |
in |
ifile |
stdin
|
input data |
in.year |
field |
FIELD("year")
|
input year in encode mode |
in.month |
field |
FIELD("month")
|
input month in encode mode |
in.day |
field |
FIELD("day")
|
input day starting from 1 in encode mode |
in.hour |
field |
FIELD("hour")
|
input hour in encode mode |
in.min |
field |
FIELD("min")
|
input minute in encode mode |
in.sec |
field |
FIELD("sec")
|
input second in encode mode |
in.epoch |
field |
FIELD("epoch")
|
input epoch in decode mode |
out |
ofile |
stdout
|
output data |
out.epoch |
str |
epoch
|
output epoch in encode mode |
out.year |
str |
year
|
output year in decode mode |
out.month |
str |
month
|
output month in decode mode |
out.day |
str |
day
|
output day in decode mode |
out.hour |
str |
hour
|
output hour in decode mode |
out.min |
str |
min
|
output minute in decode mode |
out.sec |
str |
sec
|
output second in decode mode |
Input and output
Input
input data
Output
output data