DATETEST(1)
π datetest(1) β like test(1) but make it dates π
okay bestie, listen up. this is the datetest manual page, it lives in section 1 of the manual (that's the "user commands" girlies), and it ships with dateutils 0.4.11. it's the date-flavoured remix of test(1), and honestly? she ate. let's get into it π¦
β¨ NAME β¨
datetest β like test(1) but for dates. no cap, that's the whole pitch π
β¨ SYNOPSIS β¨
datetest [OPTION]... DATE/TIME1 OP DATE/TIME2
β¨ DESCRIPTION β¨
Like test(1) but for dates. literally that's the vibe. you hand it two dates/times, you hand it an operator, she tells you if it's true. π
Recognized OPTIONs:
πΈ Recognized OPTIONs πΈ
-h,--helpβ print help and bounce βοΈ-V,--versionβ print version and bounce βοΈ-q,--quietβ shhh π€« suppresses the message about date/time and duration parser errors.-i,--input-format=STRING...β the input format, and yes you can stack it multiple times (obsessed). every date/time gets passed 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 is the one that gets used. first one that hits, wins π-b,--base=DTβ for underspecified input, useDTas the fallback to fill in the missing fields π«Ά it's also what positions the range of ambiguous format specifiers on the absolute time line. has to be a date/time in ISO8601 format. leave it off and it defaults to the current date/time.--from-locale=LOCALEβ read dates on stdin or on the command line as if they came from the localeLOCALE. this only touches month and weekday names, because input formats have to be specified explicitly (rules are rules π ).--from-zone=ZONEβ read dates on stdin or on the command line as if they came from the time zoneZONEπ-e,--backslash-escapesβ turn on interpretation of backslash escapes in the output and input format specifier strings.--eqβ DATE/TIME1 is the same as DATE/TIME2 π--neβ DATE/TIME1 is not the same as DATE/TIME2 π--gtβ DATE/TIME1 is newer than DATE/TIME2 β«--ltβ DATE/TIME1 is older than DATE/TIME2 β¬--geβ DATE/TIME1 is newer than or equals DATE/TIME2 π°β«--leβ DATE/TIME1 is older than or equals DATE/TIME2 π°β¬--ntβ DATE/TIME1 is newer than DATE/TIME2--otβ DATE/TIME1 is older than DATE/TIME2--cmpβ compare DATE/TIME1 to DATE/TIME2, and return with0if they're equal,1if the left argument was newer, and2if the right argument was newer. three-way queen π--isvalidβ return success if the dates specified conform to the input format. vibe check passed β¨
π FORMAT SPECS π
Format specs in dateutils are similar to posix's strftime(). cute, right? but because dateutils supports a way broader range of calendars, she has to employ different rules. it's giving "I'm not like other girls" and she's right π
π 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, the moment β¨)%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β okay no cap, the original manpage literally says "The " and then trails off into (range00to60,60is for leap seconds) π we're keeping it exactly as-is, typo and all%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
β οΈ heads up bestie: by design, dates before 1601-01-01 are not supported. do not push it. that's the boundary, periodt.
π Calendar designators π
for conformity, here's the 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 an output format string, and moreover, @code{lilian}/@code{ldn} and @code{julian}/@code{jdn} can also be used as an input format string. yes those @code{...} bits are in the original, we're not touching them π
π₯ EXAMPLES π₯
the real ones, straight from the source:
$ 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
$
(yes, $@{?@} is doing the most, that's just how $? got escaped in the source β leaving it verbatim because facts are facts π«‘)
π AUTHOR π
Written by Sebastian Freundt <freundt@fresse.org> β thank you for your service king π«Ά
π 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. go read it, it's the main character energy you deserve π
okay that's the whole page, you're officially fluent in datetest πβ¨ this was dateutils 0.4.11, dated November 2025 β mwah, go compare some dates bestie, ily ππ¦π
π¦ where this page comes from
- ubuntu resolute: dateutils 0.4.11-2 Β· BSD-3-Clause
- ubuntu stonking: dateutils 0.4.11-2 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms