Table of Contents
tabdate - Convert a date/time column
tabdate in_file out_file
in_format out_format
tabdate converts a file with the string
representation of one date format into another. It is simply a wrapper of
strptime(4)
to strftime(4)
.
The following parameters are recognized
in any order if the keyword is also given:
- in=
- input file name(s). No default.
- out=
- output file name. No default.
- format1=
- format to read with. The field
descriptors are explained in strptime(3)
and date(1)
. No default.
- format2=
- format to write with. No default.
- tcol=
- Columns to use for the input time.
A number of columns can be give, but they will be pasted together If none
supplied, the whole line will be used to extract the time from.
- time0=
- If
given, this will be the format (as used by format1=) to reference the time
to. The output is now forced to be format0=%s, i.e. number of seconds since
time0. The special value 0 is used to define the reference time as the first
timestamp in the file. Default: none.
% echo '2001-11-12 18:31:01' | tabtime - - '%Y-%m-%d %H:%M:%S' '%c'
Mon Nov 12 18:31:01 2001
% date +%s | tabtime - - %s %c
Mon May 9 16:16:06 2005
and a contrived way to turn time into seconds
tabdate tab0 - %T "1970 %T" | tabdate - - "%Y %T" %s
and here an example to find the number of seconds between two time-stamps:
% set t0="`date +%s`"
...
% set t1="`date +%s`"
% printf "%s0s0 "$a" "$b" | tabdate - - "%c" %s time0=0
Cannot handle fractional seconds.
date(1)
, strptime(3)
, strftime(3)
src/kernel/tab tabdate.c
Peter Teuben
1-Feb-05 V0.1 Created PJT
9-may-05 V0.2 added a working time0= and future tcol= PJT
Table of Contents