DATETEST(1)

πŸ“¦
version 0.4.11 Β· 5 versions
, in ubuntu resolute, ubuntu stonking

πŸ‘‘ 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, use DT as 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 locale LOCALE. 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 zone ZONE 🌍
  • -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 with 0 if they're equal, 1 if the left argument was newer, and 2 if 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 (range 00 to 05)
  • %C β€” the count of the weekday within the year (range 00 to 53)
  • %d β€” the day of the month, 2 digits (range 00 to 31)
  • %D β€” the day of the year, 3 digits (range 000 to 366)
  • %F β€” equivalent to %Y-%m-%d (ymd's canonical format, the moment ✨)
  • %g β€” ISO week date year without the century (range 00 to 99)
  • %G β€” ISO week date year including the century
  • %j β€” equivalent to %D
  • %m β€” the month in the current calendar (range 00 to 12)
  • %Q β€” the quarter of the year (range Q1 to Q4)
  • %q β€” the number of the quarter (range 01 to 04)
  • %s β€” the number of seconds since the Epoch.
  • %u β€” the weekday as number (range 01 to 07, Sunday being 07)
  • %U β€” the week count, day of week is Sun (range 00 to 53)
  • %V β€” the ISO week count, day of week is Mon (range 01 to 53)
  • %w β€” the weekday as number (range 00 to 06, Sunday being 00)
  • %W β€” the week count, day of week is Mon (range 00 to 53)
  • %y β€” the year without a century (range 00 to 99)
  • %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 (range 00 to 23)
  • %I β€” the hour of the day using a 12h clock, 2 digits (range 01 to 12)
  • %M β€” the minute (range 00 to 59)
  • %N β€” the nanoseconds (range 000000000 to 999999999)
  • %p β€” the string AM or PM, noon is PM and midnight is AM.
  • %P β€” like %p but in lowercase
  • %S β€” okay no cap, the original manpage literally says "The " and then trails off into (range 00 to 60, 60 is 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 altogether
  • th β€” suffix, read and print ordinal numbers
  • b β€” 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-%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 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