STRPTIME(1)
π STRPTIME π
okay so bestie, this is the manual page for the strptime command from the dateutils fam, and I'm gonna walk you through every single crumb of it like we're texting at 2am π«Ά no skipping, no summarizing, we're doing the whole thing π
πΈ NAME πΈ
strptime β parse input from stdin according to one of the given formats, the FORMATs. that's the vibe, that's the job π
π¦ SYNOPSIS π¦
strptime [OPTION]... [INPUT]...
β¨ DESCRIPTION β¨
so like, strptime parses input from stdin according to one of the given formats, the FORMATs. the format string specifiers are literally the same ones as for strptime(3), so if you already know those you're already winning π
here are the OPTIONs it recognizes:
π OPTIONS π
-h,--helpβ prints help and then dips out (exits).-V,--versionβ prints the version and then dips out too.-t,--timeβ also shows the time in the output. by default it just shows the date, no clock energy.-q,--quietβ suppresses the message about date/time and duration parser errors. like, shhh π€«-f,--format=STRINGβ the output format. this can either be a specifier string (similar tostrftime()'sFMT) or the name of a calendar.-i,--input-format=STRING...β the input format, and yes you can use it multiple times π₯ each date/time gets passed to the input format parsers in the order they're given, and if a date/time can be read successfully with a given input format specifier string, that value gets used. first one to hit, wins.-e,--backslash-escapesβ turns on interpretation of backslash escapes in the output and input format specifier strings. spooky little slashes get meaning now β¨-l,--localeβ makes the internalstrptime(3)andstrftime(3)behave in a locale dependent way. default is to pretendLC_ALL=Cis in place, so it's fake-C-coded unless you say otherwise.
π FORMAT SPECS π
format specs in dateutils are similar to posix's strftime(). but β and this is the tea β because dateutils supports a way broader range of calendars, it has to employ different rules. so don't come in here expecting pure posix behavior, bestie π«
π 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, iconic)%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)
and now the roman numeral girlies ποΈ
%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 (range00to60,60is for leap seconds). yes bestie the original really does just say "The" there and then move on, I'm keeping it π― as written, no editing the source fr fr%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 even try it, bestie, it's not a glitch it's a design choice π
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, and moreover, @code{lilian}/@code{ldn} and @code{julian}/@code{jdn} can also be used as input format string. (yes those @code{} bits are literally in the source, texinfo leaks and all, we don't gatekeep π)
π₯ EXAMPLES π₯
$ strptime -i '%a, %b-%d/%Y' 'Mon, May-01/2000'
2000-05-01
$
and the stdin version, because why type twice:
$ strptime -i '%a, %b-%d/%Y' <<EOF
Mon, May-01/2000
Mon, Mar-2/2000
EOF
2000-05-01
2000-03-02
$
look at that. parsed. slayed. β¨
π AUTHOR π
written by Sebastian Freundt <freundt@fresse.org> β the icon, the legend π
π REPORTING BUGS π
report bugs to: https://github.com/hroptatyr/dateutils/issues
π¦ SEE ALSO π¦
the full documentation for strptime is maintained as a Texinfo manual. if the info and strptime programs are properly installed at your site, the command
info (dateutils)strptime
should give you access to the complete manual. go read it, it's giving reference material π
dateutils 0.4.10 Β· February 2023 β that's the version and the date bestie, straight from the footer, mwah π stay parsed, stay iconic, periodt ππβ¨
π¦ where this page comes from
- debian bookworm: dateutils 0.4.10-1 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms