DATETEST(1)
π NAME π
okay so datetest β imagine test(1) but make it dates. that's the whole pitch bestie, no cap. it's a section 1 manual page (User Commands), so it's the real deal, main character energy only. π¦
β¨ SYNOPSIS β¨
datetest [OPTION]... DATE/TIME1 OP DATE/TIME2
π DESCRIPTION π
Like test(1) but for dates. literally that. fr fr.
here's every OPTION it knows about:
-h,--helpβ print help and exit. the "what do i even do here" button π«Ά-V,--versionβ print version and exit. say hi to the number, then bounce.-q,--quietβ suppress message about date/time and duration parser errors. shhh. π€«-i,--input-format=STRING...β input format, can be used multiple times. every date/time gets handed to the input format parsers in the order you gave them, and if a date/time can be read successfully with a given input format specifier string, that value will be used. yes you can stack these. iconic. β¨-b,--base=DTβ for underspecified input useDTas a fallback to fill in missing fields. also used for ambiguous format specifiers to position their range on the absolute time line. must be a date/time in ISO8601 format. if you omit it, it defaults to the current date/time. πΈ--from-locale=LOCALEβ interpret dates on stdin or the command line as coming from the localeLOCALE. heads up tho, this would only affect month and weekday names, since input formats have to be specified explicitly.--from-zone=ZONEβ interpret dates on stdin or the command line as coming from the time zoneZONE.-e,--backslash-escapesβ enable interpretation of backslash escapes in the output and input format specifier strings.--eqβDATE/TIME1is the same asDATE/TIME2--neβDATE/TIME1is not the same asDATE/TIME2--gtβDATE/TIME1is newer thanDATE/TIME2--ltβDATE/TIME1is older thanDATE/TIME2--geβDATE/TIME1is newer than or equalsDATE/TIME2--leβDATE/TIME1is older than or equalsDATE/TIME2--ntβDATE/TIME1is newer thanDATE/TIME2--otβDATE/TIME1is older thanDATE/TIME2--cmpβ compareDATE/TIME1toDATE/TIME2, return with0if equal,1if left argument was newer and2if right argument was newer--isvalidβ return success if dates specified conform to input format.
π FORMAT SPECS π
format specs in dateutils are similar to posix' strftime(). β¨
<b>however</b>, due to a broader range of supported calendars dateutils must employ different rules. (she's flexible like that π )
π Date specs
%aβ the abbreviated weekday name%Aβ the full weekday name%_aβ the weekday name shortened to a single character (MTWRFAS)%bβ the abbreviated month name%Bβ the full month name%_bβ the month name shortened to a single character (FGHJKMNQUVXZ)%cβ the count of the weekday within the month (range00to05)%Cβ the count of the weekday within the year (range00to53)%dβ the day of the month, 2 digits (range00to31)%Dβ the day of the year, 3 digits (range000to366)%Fβ equivalent to%Y-%m-%d(ymd's canonical format)%gβ ISO week date year without the century (range00to99)%Gβ ISO week date year including the century%jβ equivalent to%D%mβ the month in the current calendar (range00to12)%Qβ the quarter of the year (rangeQ1toQ4)%qβ the number of the quarter (range01to04)%sβ the number of seconds since the Epoch.%uβ the weekday as number (range01to07, Sunday being07)%Uβ the week count, day of week is Sun (range00to53)%Vβ the ISO week count, day of week is Mon (range01to53)%wβ the weekday as number (range00to06, Sunday being00)%Wβ the week count, day of week is Mon (range00to53)%yβ the year without a century (range00to99)%Yβ the year including the century%_yβ the year shortened to a single digit%Zβ the zone offset in hours and minutes (HH:MM) with a preceding sign (+for offsets east of UTC,-for offsets west of UTC)%Odβ the day as roman numerals%Omβ the month as roman numerals%Oyβ the two digit year as roman numerals%OYβ the year including the century as roman numerals%rsβ in time systems whose Epoch is different from the unix Epoch, this selects the number of seconds since then.%rYβ in calendars with years that don't coincide with the Gregorian years, this selects the calendar's year.%dthβ the day of the month as an ordinal number,1st,2nd,3rd, etc.%mthβ the month of the year as an ordinal number,1st,2nd,3rd, etc.%dbβ the business day of the month (since last month's ultimo)%dBβ number of business days until this month's ultimo
π§ Time specs
%Hβ the hour of the day using a 24h clock, 2 digits (range00to23)%Iβ the hour of the day using a 12h clock, 2 digits (range01to12)%Mβ the minute (range00to59)%Nβ the nanoseconds (range000000000to999999999)%pβ the stringAMorPM, noon is PM and midnight is AM.%Pβ like%pbut in lowercase%Sβ the (range00to60,60is for leap seconds)%Tβ equivalent to%H:%M:%S
π General specs
%nβ a newline character%tβ a tab character%%β a literal%character
π Modifiers
%Oβ modifier to turn decimal numbers into Roman numerals%rβ modifier to turn units into real units%0β modifier to turn on zero prefixes%SPCβ modifier to turn on space prefixes%-β modifier to turn off prefixes altogetherthβ suffix, read and print ordinal numbersbβ suffix, treat days as business days
by design dates before 1601-01-01 are not supported. so don't come for her about that. π
for conformity here is a list of calendar designators and their corresponding format string:
ymd %Y-%m-%d
ymcw %Y-%m-%c-%w
ywd %rY-W%V-%u
bizda %Y-%m-%db
lilian n/a
ldn n/a
julian n/a
jdn n/a
matlab n/a
mdn n/a
these designators can be used as output format string, moreover, @code{lilian}/@code{ldn} and @code{julian}/@code{jdn} can also be used as input format string.
π₯ EXAMPLES π₯
watch her work:
$ datetest 2012-03-01 --gt 2012-03-02 || echo "false"
false
$
$ datetest 2012-03-01 --ot 2012-03-02 && echo "true"
true
$
$ datetest 2012-03-01 --cmp 2012-03-02; echo $?
2
$
$ datetest 2012-03-02 --cmp 2012-03-02; echo $?
0
$
$ datetest 2012-03-02 --cmp 2012-03-01; echo $?
1
$
$ datetest 12:00:04 --gt 11:22:33 && echo "true"
true
$
$ datetest 12:00:04 --lt 11:22:33 || echo "false"
false
$
$ datetest 12:00:04 --cmp 11:22:33; echo "$@{?@}"
1
$
$ datetest --cmp 11:22:33 12:00:04; echo "$@{?@}"
2
$
$ datetest --ne 2012-03-02T00:00:00 2012-03-02 || echo 'false'
false
$
$ datetest 2012-03-02T09:00:00 --ot 2012-03-02T10:00:00 && echo "true"
true
$
$ datetest 2012-03-02T07:00:00 --cmp 2012-03-02T09:30:00; echo "$@{?@}"
2
$
$ datetest --cmp 2012-03-02T12:00:00 2012-03-02T09:30:00; echo "$@{?@}"
1
$
$ datetest 2012-03-02T07:00:00 --cmp 09:30:00; echo "$@{?@}"
3
$
πΈ AUTHOR πΈ
Written by Sebastian Freundt <freundt@fresse.org>
π«Ά REPORTING BUGS π«Ά
Report bugs to: https://github.com/hroptatyr/dateutils/issues
β SEE ALSO β
the full documentation for datetest is maintained as a Texinfo manual. if the info and datetest programs are properly installed at your site, the command
info (dateutils)datetest
should give you access to the complete manual. iykyk β¨
and that's the whole page bestie β this was dateutils 0.4.11, dated January 2024, section 1 of the manual. go forth and compare some dates π π
π¦ where this page comes from
- alpine 3.24: dateutils-doc 0.4.11-r0 Β· BSD-3-Clause
- fedora 43: dateutils 0.4.11-5.fc43 Β· BSD-3-Clause
- fedora 44: dateutils 0.4.11-7.fc44 Β· BSD-3-Clause
- nixos 26.05: dateutils 0.4.11
- nixpkgs unstable: dateutils 0.4.11
- opensuse-leap 16.0: dateutils 0.4.11-bp160.1.17 Β· BSD-3-Clause
- opensuse-leap 16.0: dateutils 0.4.11-bp160.1.17 Β· BSD-3-Clause
- opensuse-leap 16.0: dateutils 0.4.11-bp160.1.17 Β· BSD-3-Clause
- opensuse-leap 16.0: dateutils 0.4.11-bp160.1.17 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms