DATETEST(1)
β¨ NAME β¨
Bestie, meet datetest(1) β itβs literally like test(1) but for dates. Thatβs the whole pitch. No cap, itβs the date-comparison bestie you didnβt know you needed. π
πΈ SYNOPSIS πΈ
datetest [OPTION]... DATE/TIME1 OP DATE/TIME2
π¦ DESCRIPTION π¦
Like test(1) but for dates. Yes, thatβs the whole vibe. π«Ά You hand it two dates/times and an operator situation, and it tells you whatβs up.
π Recognized OPTIONs π
-h,--helpβ prints help and exits. Iconic.-V,--versionβ prints version and exits. Slay.-q,--quietβ suppresses the message about date/time and duration parser errors. Less noise, same drama.-i,--input-format=STRING...β input format, and yes you can use it multiple times. Each date/time will be passed to the input format parsers in the order they are given; if a date/time can be read successfully with a given input format specifier string, that value will be used. Big brain energy.-b,--base=DTβ for underspecified input, useDTas a fallback to fill in missing fields. Itβs also used for ambiguous format specifiers to position their range on the absolute time line.DTmust be a date/time inISO8601format. If omitted, it defaults to the current date/time.--from-locale=LOCALEβ interpret dates on stdin or the command line as coming from the localeLOCALE. This would only affect month and weekday names, as 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 the left argument was newer and2if the right argument was newer. The receipts are built in.--isvalidβ return success if dates specified conform to input format.
π§ FORMAT SPECS π§
Format specs in dateutils are similar to posix' strftime(). However, due to a broader range of supported calendars, dateutils must employ different rules. Periodt.
π 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 isPMand midnight isAM.%Pβ like%pbut in lowercase.%Sβ the seconds (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 altogether.thβ suffix, read and print ordinal numbers.bβ suffix, treat days as business days.
β οΈ By design, dates before 1601-01-01 are not supported. Thatβs the limit, bestie. π
For conformity, hereβs a list of calendar designators and their corresponding format string:
ymdβ%Y-%m-%dymcwβ%Y-%m-%c-%wywdβ%rY-W%V-%ubizdaβ%Y-%m-%dblilianβn/aldnβn/ajulianβn/ajdnβn/amatlabβn/amdnβ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 π
Okay so these examples literally use dtest as written β copy them exactly, bestie, we donβt βfixβ the command name here. π
$ dtest 2012-03-01 --gt 2012-03-02 || echo "false"
false
$
$ dtest 2012-03-01 --ot 2012-03-02 && echo "true"
true
$
$ dtest 2012-03-01 --cmp 2012-03-02; echo $?
2
$
$ dtest 2012-03-02 --cmp 2012-03-02; echo $?
0
$
$ dtest 2012-03-02 --cmp 2012-03-01; echo $?
1
$
$ dtest 12:00:04 --gt 11:22:33 && echo "true"
true
$
$ dtest 12:00:04 --lt 11:22:33 || echo "false"
false
$
$ dtest 12:00:04 --cmp 11:22:33; echo "$@{?@}"
1
$
$ dtest --cmp 11:22:33 12:00:04; echo "$@{?@}"
2
$
$ dtest --ne 2012-03-02T00:00:00 2012-03-02 || echo 'false'
false
$
$ dtest 2012-03-02T09:00:00 --ot 2012-03-02T10:00:00 && echo "true"
true
$
$ dtest 2012-03-02T07:00:00 --cmp 2012-03-02T09:30:00; echo "$@{?@}"
2
$
$ dtest --cmp 2012-03-02T12:00:00 2012-03-02T09:30:00; echo "$@{?@}"
1
$
$ dtest 2012-03-02T07:00:00 --cmp 09:30:00; echo "$@{?@}"
3
$
π AUTHOR π
Written by Sebastian Freundt <freundt@fresse.org>. Author slay.
π REPORTING BUGS π
Report bugs to: https://github.com/hroptatyr/dateutils/issues. The maintainers want the tea. β
π 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. Periodt.
π dateutils 0.4.11 Β· January 2024 β thatβs the footer, bestie. Mwah. π
π¦ where this page comes from
- alpine 3.24: dateutils-doc 0.4.11-r0 Β· 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-1017 on : a language model's rewrite of the original, under its terms