STRPTIME(1)
π strptime β the dateutils glow-up π
okay so bestie, welcome to strptime from the dateutils family. this little icon takes input from stdin and parses it according to one of the given formats, the FORMATs. that's the whole vibe. she reads, she interprets, she serves. π
β¨ SYNOPSIS β¨
strptime [OPTION]... [INPUT]...
πΈ DESCRIPTION πΈ
Parse input from stdin according to one of the given formats FORMATs. no cap, that's her whole job.
the format string specifiers are exactly the same as for strptime(3). so if you already know that one, you're set, iykyk. π
here are the recognized OPTIONs:
-h,--helpβ print help and exit. she'll tell you what's up, then dip.-V,--versionβ print version and exit. quick little flex.-t,--timeβ also display time in the output. default is to display just the date. so if you want the whole timestamp moment, this is your girl. π-q,--quietβ suppress the message about date/time and duration parser errors. she just won't mention it. silent treatment, but make it productive.-f,--format=STRINGβ output format. this can either be a specifier string (similar tostrftime()'sFMT) or the name of a calendar. your call bestie. β¨-i,--input-format=STRING...β input format, can be used multiple times. each date/time will be passed to the input format parsers in the order they are given, and if a date/time can be read successfully with a given input format specifier string, that value will be used. it's like trying on outfits until one fits. π-e,--backslash-escapesβ enable interpretation of backslash escapes in the output and input format specifier strings.\ngirlies rise up.-l,--localeβ make internalstrptime(3)andstrftime(3)behave in a locale dependent way. default is to pretendLC_ALL=Cis in place. so she's pretending to be a very neutral, no-accent English speaker unless you tell her otherwise. π
π 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. (she's got range. she contains multitudes.)
π 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)%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)
and the roman numeral era:
%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
and the calendar-specific girlies:
%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.
and the ordinal ones (so cutesy):
%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.
and the business day ones (girlboss energy):
%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 stringAMorPM, noon is PM and midnight is AM.%Pβ like%pbut in lowercase%Sβ the (range 00 to 60, 60 is for leap seconds)%Tβ equivalent to%H:%M:%S
no bestie, that %S line really does have a double space and no word before the parenthesis in the original. i'm not making that up, i promise. π she said "the " and then moved on.
β 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. she has boundaries. she has a birth certificate. don't push her. π«
for conformity here is 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, lilian/ldn and julian/jdn can also be used as input format string. (yes, the original really does have the raw @code{...} markup in there. iconic of her honestly.) β¨
π EXAMPLES π
single date, one line, immaculate:
$ strptime -i '%a, %b-%d/%Y' 'Mon, May-01/2000'
2000-05-01
$
and now via a heredoc, because she can multitask:
$ strptime -i '%a, %b-%d/%Y' <<EOF
Mon, May-01/2000
Mon, Mar-2/2000
EOF
2000-05-01
2000-03-02
$
π AUTHOR
written by Sebastian Freundt <freundt@fresse.org>. king behavior, we love to see it. π«Ά
π 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 bestie, it's giving scholarly. π
and that's the whole page, mwah π this was dateutils 0.4.11, dated January 2024, for STRPTIME(1). thank you for coming to my ted talk, ily, bye! πβ¨
π¦ 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