HTML automatically generated with rman
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.
- dcol=
- Column to use for the input date/time.
If none supplied (or 0 used), the whole line will be used to extract the
time from. This might be useful if the date and time are in separate columns.
Default: 0
- 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.
- scale=
- Scale factor used when a time0= is used, and by which the time in seconds
since time0 is divided to get more reasonable units. Default: 1
Although
the field descriptors are described in e.g.strptime(3)
and date(1)
, here
is a very brief summary of the common ones:
%a,%A weekday name
%b,%B,%h month name
%c full date and time
%C century number (0-99)
%d,%e day in month (0-31)
%D Equivalent to %m/%d/%y
%H hour (0-23)
%j day number in year (1-366)
%m month number (1-12)
%M minute (0-59)
%S second (0-60),60 is for a leap second
%T Equivalent to %H:%M:%S
%y year within century (0-99)
%Y full year, e.g. 1991
% echo ’2001-11-12 18:31:01’ | tabdate - - ’%Y-%m-%d %H:%M:%S’ ’%c’
Mon Nov 12 18:31:01 2001
% date +%s | tabdate - - %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
4-apr-09 V0.3 added dcol= (instead of tcol=), fixed initializtion PJT
Table of Contents