jdc { -j | -d | -D } options [ format-options ] date-recordor
proc | jdc { -j | -d | -D } -i options [ format-options ]
PURPOSE: Convert Julian date to Kalendar or vice
versa or re-format Kalendar dates.
Replace
/ inject / generate date records
In the second form, proc may generate a list of date
records or,
more
generally, records with dates embedded.
OBS! In
perl scripts, chomp($r = `jdc -m0 options ...`)
chomp()
and option -m0 are required,
else the resulting
string will end with char(0)\n.
Default input format: The date record may be a bare date or a string containing a date.
Give year with four digits, the rest with two digits but with -k4, millisecond with three digits.
Three delimiters are possible: blank, comma, slash.
If given on the command line, the string that is processed is concatenated with
one blankspace between each part. Formatting options are available to adapt other layouts.
The predecessor program JDC is obsolete (it's still in use on Brimer)
CHANGES w.r.t. JDC:
No RJD nor full JD.
No Time Zone option.
More logic in the options.
More clarity in output record construction.Still missing: UTC leap-seconds (really? What would we expect in a date conversion?)
ARGUMENTS / OPTIONS:
Compulsory:
-j[i][D][{y|h|s|f}]] ...
- Convert Julian date x
to kalendar form.
In the -ji case, x
is read as an integer.
D or d
- Output date as year and day-of-year.
y - Output date as a
floating-point year, format f15.8
h - Output date, ending
with a floating-point hour, format f12.6
f - Output date down to the fractional second
s - Output date and time of day as a fractional second
(format f10.3)
-d[y|D][{I|i}][{h|s}][[{C|c}]yyyy,mm,dd[,hh[,mi[,se[,fff]]]]]
... yyyy mm dd
[hh [mi [se
[fff]]]]
-d[y|D]M[s]
... yyyy mm dd [hh [mi
[se [fff]]]]
- Convert kalendar form to Julian date
y - input date (above in red)
is a floating-point year.
D
or d - input date as year and
day-of-year: yyyy doy
Tolerable delimiters besides ` ´ are
`-´ `,´ `.´ `_ ´ and `:´
(doy concerns the target date, not the reference
date.
If you want to give the
reference date as year,doy ,
specify yyyy,0,doy )
i - output as an integer
with format i5.5
I -
output as an integer with format *
The date
[M]h [M]s
- without M, scale output with 24 or 86400,
respectively.
With M, output integer Julian day and floating point
hour [default] or, with s, second, respectively.
date string
- (above in black) output relative to ( = "subtract" ) this
date.
The date string may use `:´ and `-´, and, if
quoted, ` ´ as delimiters.
Example:
jdc -ds"2022-03-16 14:34:27" -k3 2022-03-16 14:56:49
returns difference in seconds
-D[D[d]|d[ifmt]][{y|h}ffmt]
yyyy mm dd [hh [mi
[se [fff]]]]
-
Output orthodox date (rectified for out-of-range values)
-Dd - output date as year and day-of-year.
-DD - input date as year and
day-of-year.
-DDd
- input and output as year and
day-of-year.
-Dy -
output floating-point year
-Dh - output yyyy mm
dd and floating-point hour
-DHffmt
- input yyyy mm dd and floating-point
hour
-DSffmt
- input yyyy mm dd and
floating-point second
ifmt - the format
code pertaining to year month day output
In the case of day-of-year output, the month must be
overwritten:
jdc -DDdi4,i2,t5,i4 -k3 2014
367 12 10 1
2015 002 12 10 01
ffmt - the format code,
case -Dh including year month day and parentheses,
example:
jdc -Dh'(i4,2i3.2,f9.6)'
-As1246.88 -k4 2017 07 11 07 00 01 190
2017 07 11 7.346686
Optional:
-DB
- Debug printing. Don't expect
too much.
-C[{y|h}fmt] - Conversion
from date to floating-point year (like -Dy) or
yyyy mm dd h.hhh (like -Dh)
-b#r1[,#r2] - date part of input string
is contained in columns r1..r2
Default: 1..end.
-i[#c1,#c2,#c3,#c4]
- read from stdin (file mode). Default: command line.
-I[#c1,#c2,#c3,#c4]
- take
input from command line, long string with more than the
bare time information.
-m
- Suppress the default ASC=0 delimiter (important if output to
pipe).
(We need a different default, why the heck the ASC 0 !?)
Changed 2015-04-05 If there's trouble (if char(0) is needed
somewhere, we
must change
back or add a char(0)-option, like -m@
-m
- trailing delimiter in output is one blankspace
-m:d[]] - delimiter
string d, max length
16, to inject after date and time
For trailing blanks, enter string as 'd]'
-mb#n
- blank delimiter, length n
-m0
- no
trailing delimiter, length 0
-td[]] -
trailing delimiter string d, max length 16, to inject
after date and time.
For trailing blanks, enter string d with a trailing `]´
-tb#n
- blank
delimiter, length n
-kk - Input and output: depth of hh mm ss fff part. k=0..4
-n[{i|u}]p... - output month in character form,
default: lower-case.
.............i -
capitalize initial (Jan Feb etc.)
u - convert to
upper-case.
p - the position of
the month number in the input string
-N[{i|u}]p,q
- input month in character form, like -n . The month
name
occupies input string positions p:q
-A[h|m|s]j -S[h|m|s]j
- Add, or subtract j days to/from
date.
.............h - value j
is in hours.
.............m - value j
is in minutes.
.............s - value j
is in seconds.
-{A|S}ryyyy,mm,dd[,hh[,mm[,ss[,fff]]]]
- ... output date is relative to this date.
Delimiters `-´ and `:´ are tolerated.
-L#m,#n
- Loop from m to n with time increment
specified under -A or -S
Example:
JDC -D -k3 -Am1 -L0,3 2012 01 06
2012 01 06 00 00 00
2012 01 06 00 01 00
2012 01 06 00 02 00
2012 01 06 00 03 00
-F:fmt
- Input format (avoid outer parentheses), default is
[t1,i4,2(1x,i2),1x,2(i2,1x ),i2,1x,i3]
-f:fmt
- Output .. , default is
(t1, i4, 1h ,i2.2, 1h ,i2.2:, a ,2(i2.2,:,1h ),i2.2,:,1h ,i3.3 )
Note the `a´ --------------------^ !
There is a delimiter written out at this position. You will
need
to code this `a´ while the delimiter might be blank or NUL,
escaping your notice.
(I need to review this; it's ugly, sorry. Also the -m option
is a nuisance.)
-FF
- Reading date with free format (*)
-FT -FS
- Input format "tight" or "short", i.e. no delimiters between
the
parts, "short" meaning 2-digit year
-FTd -FSd d
- can be any character; a delimiter length 1 is honored between
date and time
-T#c
- Input date-and-time string starts at position c.
-ft -fs
- Output format "tight" or "short", i.e. no delimiters between
the
parts, "short" meaning 2-digit year
Cannot be combined with -- or -, or -: If you need a
delimiter
between YMD and HMS, ...
-ftd -fsd - Use d
(single char) as the delimiter between YMD and HMS.
Allowed are: : , -
. + /
_ b , the latter meaning a whitespace.
Example: jdc -ft, -k3 -DD 2014:162
20140611,000000
-fi:fmt
- Format for Julian integer input/output. Default i5.5 .
-Fi:fmt
synonymous
-MDY
-DMY - ordering
of Year Month Day in input. Output is always YMD
-YY[{i[o][#y]|o}]
- 2-digit year on input, output or both (-YYio).
#y - Switch 1900/2000 at
year y (two digits).
Default=50
-P#n
- prepend output string with n blanks.
-pstring
- prepend output string with string
-,
-
write
comma-separated dates.
--
- write Y-M-D h m s
-:
-
write Y-M-D h:m:s
-::
- write Y-M-D:h:m:s
-:::
- write Y:M:D:h:m:s
-/
- write Y/M/D h m s
-/ -:
- write Y/M/D h:m:s
-/ -::
- write Y/M/D:h:m:s
-//
- write
Y/M/D h/m/s
-///
- write Y/M/D/h/m/s
--:
- write Y-M-D
h:m:s
--:_
- write Y-M-D_h:m:s
Default: blank-separated output.
-B[r]
- Allow leading blanks in output. Replace each
leading blank with r
Not implemented yet:
-s[h]
-
kalendar
form is yyyy mm dd s with floating-point seconds (hours)
Format redefinitions must
occur last of all options. Use these options
if the automatically generated/modified formats are
inappropriate.
-F:fmt - input format.
-f:fmt
- output format.
NOTE:
If the date part on the command line is empty, the program
will try input from <stdin>
EXAMPLES:
(1) Rectifying out-of-range
jdc -D -k3 2003 01 01 -2 59 20
2002 12 31 22 59 20
jdc -D 2003 01 00
2002 12 31
jdc -D 2003 01 99
2003 04 09
jdc -D 2003 99 99
2011 06 07
jdc -DD 2003 366
2004 01 01
(2)
Date format conversion:
Add a blank between tightly written date and the hour:
jdc -k1 -m -FT -f:i4,2i2.2,a,i2.2 -D 2012120105
20121201 05
adding 132 hours to the date:
jdc -k1 -m -FT -f:i4,2i2.2,a,i2.2 -Ah132 -D 2012120105
20121206 17
(3)
GWR file names. Produce a sequence of file names
jdc -D -FS -fs -A1 -L0,15 -m -b12,17 -I1,11,18,21
RAW_o054/A1090701.054
RAW_o054/A1090701.054
RAW_o054/A1090702.054
RAW_o054/A1090703.054
RAW_o054/A1090704.054
RAW_o054/A1090705.054
RAW_o054/A1090706.054
RAW_o054/A1090707.054
RAW_o054/A1090708.054
RAW_o054/A1090709.054
RAW_o054/A1090710.054
RAW_o054/A1090711.054
RAW_o054/A1090712.054
RAW_o054/A1090713.054
RAW_o054/A1090714.054
RAW_o054/A1090715.054
RAW_o054/A1090716.054
12345678901234567890123456789012345678901234567890123456789012345678901234567890
1
2
3
4
5
6
7 8
We have a helper script for the -b and -I options:
/home/hgs/bin/jdch
jdc -D -L0,10 -A1 -FS -fs -m -b24,29 -I1,23,30,35
/home/hgs/TD/d/G1_garb_130109-1s.mc
jdc -D -L0,10 -A1 -FS -fs -m `jdch '/home/hgs/TD/d/G1_garb_{130109}-1s.mc'`
set mfile='/home/hgs/TD/d/G1_garb_{130109}-1s.mc'
jdc -D -L0,10 -A1 -FS -fs -m `jdch
"$mfile"`
/home/hgs/TD/d/G1_garb_130109-1s.mc
/home/hgs/TD/d/G1_garb_130110-1s.mc
/home/hgs/TD/d/G1_garb_130111-1s.mc
/home/hgs/TD/d/G1_garb_130112-1s.mc
/home/hgs/TD/d/G1_garb_130113-1s.mc
/home/hgs/TD/d/G1_garb_130114-1s.mc
/home/hgs/TD/d/G1_garb_130115-1s.mc
/home/hgs/TD/d/G1_garb_130116-1s.mc
/home/hgs/TD/d/G1_garb_130117-1s.mc
/home/hgs/TD/d/G1_garb_130118-1s.mc
/home/hgs/TD/d/G1_garb_130119-1s.mc
12345678901234567890123456789012345678901234567890123456789012345678901234567890
1
2
3
4
5
6
7 8
jdc -L1,1665,24 -m -D -A1 -fs
-f:'2h??,3i2.2,4h.054' 2009 06 10
??090611.054
??090612.054
??090613.054
??090614.054
??090615.054
??090616.054
??090617.054
??090618.054
??090619.054
??090620.054
...
(4)
Guralp file names. Produce a whole sequence of 65 file names.
Input is a y-m-d kalendar date
jdc -L0,65 -Am10 -:: -k3
-T5 -I1,4,24,36 -m -Dd
GCF.2011-06-15 01:10:00.3U93Z2.ts
GCF.2011:166:01:10:00.3U93Z2.ts
GCF.2011:166:01:20:00.3U93Z2.ts
GCF.2011:166:01:30:00.3U93Z2.ts
GCF.2011:166:01:40:00.3U93Z2.ts
...
-L0,65
- the loop from 0 to 65
-Am10 -
add 10 minutes every pass
-::
- colons after YYYY and DOY
-k3
- HH MM SS in input and output
-T5 - input
string, date starts at column 5
-I1,4,24,36
- copy
columns 1-4 as the leading output
and 24-36 as the trailing output
-m
- avoid ASCII(0) as a delimiter
-Dd
- from kalendar date to YYY DOY.
(5)
Convert calendar dates in a time series file to MJD
2003 01 01 00 data...................
2003 01 01 01 data...................
cat file | jdc
-i1,0,14,-1 -d -k1 -mb -f:f10.3
gives
52640.000 data...................
52640.042 data...................
(6)
Write calendar data for labelling an axis in GMT
jdc -d -A1 -k1 -L0,10 2013 08 01 12 | jdc -mb -i1,13,14,15
-j | awk '{print $1,"0.5 12 0 1 2",$4}'
56505.500000 0.5 12 0 1 2 01
56506.500000 0.5 12 0 1 2 02
56507.500000 0.5 12 0 1 2 03
56508.500000 0.5 12 0 1 2 04
56509.500000 0.5 12 0 1 2 05
56510.500000 0.5 12 0 1 2 06
56511.500000 0.5 12 0 1 2 07
56512.500000 0.5 12 0 1 2 08
56513.500000 0.5 12 0 1 2 09
56514.500000 0.5 12 0 1 2 10
56515.500000 0.5 12 0 1 2 11
(7)
tp-mc files in AG-Supercampaigns:
tslist o/scg-cal-merged-O.dc.mc -LM -LD -Ni -n
-Ff15.6,f10.2 -MQ -qqq
1 55012.979167
0.00
2 55012.979282 -44.68
3 55012.979398 -44.68
4 55012.979514 -44.68
5 55012.979630 -44.68
6 55012.979745 -44.68
tslist o/scg-cal-merged-O.dc.mc -LM -LD -Ni -n
-Ff15.6,f10.2 -MQ -qqq |\
jdc -j -k3 -i1,0,30,40 -m -F:'t17,f15.0'
2009 06 30 23 30
00 0.00
2009 06 30 23 30 09 -44.68
2009 06 30 23 30 19 -44.68
2009 06 30 23 30 30 -44.68
2009 06 30 23 30 40 -44.68
2009 06 30 23 30 49 -44.68
cd TD/a/Allcamps
tslist o/scg-cal-merged-O-expf.ra.mc -LM -LR -LS
-TPSs20,+BE -Ft1,f13.7,1p,2e12.4 |\
jdc -i1,0,15,40 -l'>' -k3 -m -j
>
2009 06 30 23 29 59 -3.6386E+00 9.9724E-01
2009 06 30 23 38 10 -3.6386E+00 9.9724E-01
>
2009 07 01 00 30 04 7.7954E+00 1.0527E+00
2009 07 01 00 38 14 7.7954E+00 1.0527E+00
tslist o/scg-cal-merged-O-expf.ra.mc -LM -LR -LS
-TPSs20,+BE -Ft1,f13.7,1p,2e12.4 |\
jdc -i1,0,15,40 -l'>' -m
-jy
>
2009.50028519 -3.6386E+00 9.9724E-01
2009.50030072 -3.6386E+00 9.9724E-01
>
2009.50039943 7.7954E+00 1.0527E+00
2009.50041495 7.7954E+00 1.0527E+00
We have more examples (for the old JDC program however. Must be rewritten)
.bye