1DATETEST(1)                      User Commands                     DATETEST(1)
2
3
4

NAME

6       datetest - Like test(1) but for dates.
7

SYNOPSIS

9       datetest [OPTION]...  DATE/TIME1 OP DATE/TIME2
10

DESCRIPTION

12       Like test(1) but for dates.
13
14
15       Recognized OPTIONs:
16
17       -h, --help
18              Print help and exit
19
20       -V, --version
21              Print version and exit
22
23       -q, --quiet
24              Suppress message about date/time and duration parser errors.
25
26       -i, --input-format=STRING...
27              Input  format,  can be used multiple times.  Each date/time will
28              be passed to the input format parsers  in  the  order  they  are
29              given,  if a date/time can be read successfully with a given in‐
30              put format specifier string, that value will be used.
31
32       -b, --base=DT
33              For underspecified input use DT as a fallback to fill in missing
34              fields.   Also  used for ambiguous format specifiers to position
35              their range on the absolute time line.  Must be a  date/time  in
36              ISO8601 format.  If omitted defaults to the current date/time.
37
38       --from-locale=LOCALE
39              Interpret  dates on stdin or the command line as coming from the
40              locale LOCALE, this would only affect month and weekday names as
41              input formats have to be specified explicitly.
42
43       --from-zone=ZONE
44              Interpret  dates on stdin or the command line as coming from the
45              time zone ZONE.
46
47       -e, --backslash-escapes
48              Enable interpretation of backslash escapes in the output and in‐
49              put format specifier strings.
50
51       --eq   DATE/TIME1 is the same as DATE/TIME2
52
53       --ne   DATE/TIME1 is not the same as DATE/TIME2
54
55       --gt   DATE/TIME1 is newer than DATE/TIME2
56
57       --lt   DATE/TIME1 is older than DATE/TIME2
58
59       --ge   DATE/TIME1 is newer than or equals DATE/TIME2
60
61       --le   DATE/TIME1 is older than or equals DATE/TIME2
62
63       --nt   DATE/TIME1 is newer than DATE/TIME2
64
65       --ot   DATE/TIME1 is older than DATE/TIME2
66
67       --cmp  compare  DATE/TIME1  to DATE/TIME2, return with 0 if equal, 1 if
68              left argument was newer and 2 if right argument was newer
69
70       --isvalid
71              Return success if dates specified conform to input format.
72

FORMAT SPECS

74       Format specs in dateutils are similar to posix' strftime().
75
76       However, due to a broader range of supported calendars  dateutils  must
77       employ different rules.
78
79       Date specs:
80         %a  The abbreviated weekday name
81         %A  The full weekday name
82         %_a The weekday name shortened to a single character (MTWRFAS)
83         %b  The abbreviated month name
84         %B  The full month name
85         %_b The month name shortened to a single character (FGHJKMNQUVXZ)
86         %c  The count of the weekday within the month (range 00 to 05)
87         %C  The count of the weekday within the year (range 00 to 53)
88         %d  The day of the month, 2 digits (range 00 to 31)
89         %D  The day of the year, 3 digits (range 000 to 366)
90         %F  Equivalent to %Y-%m-%d (ymd's canonical format)
91         %g  ISO week date year without the century (range 00 to 99)
92         %G  ISO week date year including the century
93         %j  Equivalent to %D
94         %m  The month in the current calendar (range 00 to 19)
95         %Q  The quarter of the year (range Q1 to Q4)
96         %q  The number of the quarter (range 01 to 04)
97         %s  The number of seconds since the Epoch.
98         %u  The weekday as number (range 01 to 07, Sunday being 07)
99         %U  The week count,  day of week is Sun (range 00 to 53)
100         %V  The ISO week count,  day of week is Mon (range 01 to 53)
101         %w  The weekday as number (range 00 to 06, Sunday being 00)
102         %W  The week count,  day of week is Mon (range 00 to 53)
103         %y  The year without a century (range 00 to 99)
104         %Y  The year including the century
105         %_y The year shortened to a single digit
106         %Z  The zone offset in hours and minutes (HH:MM) with
107             a preceding sign (+ for offsets east of UTC, - for offsets
108             west of UTC)
109
110         %Od The day as roman numerals
111         %Om The month as roman numerals
112         %Oy The two digit year as roman numerals
113         %OY The year including the century as roman numerals
114
115         %rs In time systems whose Epoch is different from the unix Epoch, this
116             selects the number of seconds since then.
117         %rY In calendars with years that don't coincide with the Gregorian
118             years, this selects the calendar's year.
119
120         %dth  The day of the month as an ordinal number, 1st, 2nd, 3rd, etc.
121         %mth  The month of the year as an ordinal number, 1st, 2nd, 3rd, etc.
122
123         %db The business day of the month (since last month's ultimo)
124         %dB Number of business days until this month's ultimo
125
126       Time specs:
127         %H  The hour of the day using a 24h clock, 2 digits (range 00 to 23)
128         %I  The hour of the day using a 12h clock, 2 digits (range 01 to 12)
129         %M  The minute (range 00 to 59)
130         %N  The nanoseconds (range 000000000 to 999999999)
131         %p  The string AM or PM, noon is PM and midnight is AM.
132         %P  Like %p but in lowercase
133         %S  The  (range 00 to 60, 60 is for leap seconds)
134         %T  Equivalent to %H:%M:%S
135
136       General specs:
137         %n  A newline character
138         %t  A tab character
139         %%  A literal % character
140
141       Modifiers:
142         %O  Modifier to turn decimal numbers into Roman numerals
143         %r  Modifier to turn units into real units
144         %0  Modifier to turn on zero prefixes
145         %SPC  Modifier to turn on space prefixes
146         %-  Modifier to turn off prefixes altogether
147         th  Suffix, read and print ordinal numbers
148         b   Suffix, treat days as business days
149
150       By design dates before 1601-01-01 are not supported.
151
152       For  conformity here is a list of calendar designators and their corre‐
153       sponding format string:
154         ymd     %Y-%m-%d
155         ymcw    %Y-%m-%c-%w
156         ywd     %rY-W%V-%u
157         bizda   %Y-%m-%db
158         lilian     n/a
159         ldn        n/a
160         julian     n/a
161         jdn        n/a
162         matlab     n/a
163         mdn        n/a
164
165       These designators can  be  used  as  output  format  string,  moreover,
166       @code{lilian}/@code{ldn}  and @code{julian}/@code{jdn} can also be used
167       as input format string.
168
169

EXAMPLES

171         $ datetest 2012-03-01 --gt 2012-03-02 || echo "false"
172         false
173         $
174
175         $ datetest 2012-03-01 --ot 2012-03-02 && echo "true"
176         true
177         $
178
179         $ datetest 2012-03-01 --cmp 2012-03-02; echo $?
180         2
181         $
182
183         $ datetest 2012-03-02 --cmp 2012-03-02; echo $?
184         0
185         $
186
187         $ datetest 2012-03-02 --cmp 2012-03-01; echo $?
188         1
189         $
190
191         $ datetest 12:00:04 --gt 11:22:33 && echo "true"
192         true
193         $
194
195         $ datetest 12:00:04 --lt 11:22:33 || echo "false"
196         false
197         $
198
199         $ datetest 12:00:04 --cmp 11:22:33; echo "$@{?@}"
200         1
201         $
202
203         $ datetest --cmp 11:22:33 12:00:04; echo "$@{?@}"
204         2
205         $
206
207         $ datetest --ne 2012-03-02T00:00:00 2012-03-02 || echo 'false'
208         false
209         $
210
211         $ datetest 2012-03-02T09:00:00 --ot 2012-03-02T10:00:00 && echo "true"
212         true
213         $
214
215         $ datetest 2012-03-02T07:00:00 --cmp 2012-03-02T09:30:00; echo "$@{?@}"
216         2
217         $
218
219         $ datetest --cmp 2012-03-02T12:00:00 2012-03-02T09:30:00; echo "$@{?@}"
220         1
221         $
222
223         $ datetest 2012-03-02T07:00:00 --cmp 09:30:00; echo "$@{?@}"
224         3
225         $
226

AUTHOR

228       Written by Sebastian Freundt <freundt@fresse.org>
229

REPORTING BUGS

231       Report bugs to: https://github.com/hroptatyr/dateutils/issues
232

SEE ALSO

234       The full documentation for datetest is maintained as a Texinfo  manual.
235       If  the info and datetest programs are properly installed at your site,
236       the command
237
238              info (dateutils)datetest
239
240       should give you access to the complete manual.
241
242
243
244dateutils 0.4.9                   August 2021                      DATETEST(1)
Impressum