STRPTIME(3)
๐ STRPTIME(3) ๐
Library Functions Manual energy โ okay so bestie, this is the whole page, no skipped bits, periodt. ๐ซถ
๐ธ NAME ๐ธ
strptime โ parse date and time string
๐ LIBRARY ๐
Standard C Library (libc, -lc) โ yes bestie, that's the library right there. ๐
โจ SYNOPSIS โจ
#include <time.h>
char *
strptime(const char * restrict buf, const char * restrict format,
struct tm * restrict timeptr);
#include <time.h>
#include <xlocale.h>
char *
strptime_l(const char * restrict buf, const char * restrict format,
struct tm * restrict timeptr, locale_t loc);
๐ฆ DESCRIPTION ๐ฆ
okay so strptime() is the parser bestie. It parses the string in the buffer buf according to the string pointed to by format, and fills in the elements of the structure pointed to by timeptr. The resulting values will be relative to the local time zone. So yes, you can think of it as the reverse operation of strftime(3) โ iconic symmetry, no cap. โจ
strptime_l() does the same as strptime(), but takes an explicit locale rather than using the current locale. So if you need to pass the locale yourself, that's your girl. ๐
The format string consists of zero or more conversion specifications and ordinary characters. All ordinary characters are matched exactly with the buffer, where white space in the format string will match any amount of white space in the buffer. All conversion specifications are identical to those described in strftime(3). Literally same specs, just parsing instead of formatting. ๐
Two-digit year values, including formats %y and %D, are now interpreted as beginning at 1969 per POSIX requirements. Years 69-00 are interpreted in the 20th century (1969-2000), years 01-68 in the 21st century (2001-2068). The %U and %W format specifiers accept any value within the range 00 to 53. That's the range, bestie, don't argue. ๐
If the format string does not contain enough conversion specifications to completely specify the resulting struct tm, the unspecified members of timeptr are left untouched. For example, if format is "%H:%M:%S", only tm_hour, tm_sec and tm_min will be modified. If time relative to today is desired, initialize the timeptr structure with today's date before passing it to strptime(). That's the move. ๐ซถ
๐ฅ RETURN VALUES ๐ฅ
Upon successful completion, strptime() returns the pointer to the first character in buf that has not been required to satisfy the specified conversions in format. It returns NULL if one of the conversions failed. strptime_l() returns the same values as strptime(). Slay, but check that NULL, bestie. ๐ญ
๐ SEE ALSO ๐
โญ HISTORY โญ
The strptime() function appeared in FreeBSD 3.0. Vintage but still serving. ๐
๐ AUTHORS ๐
The strptime() function has been contributed by Powerdog Industries.
This man page was written by Jรถrg Wunsch.
๐ CAVEATS ๐
The strptime() function assumes the Gregorian calendar and will produce incorrect results for dates prior to its introduction. So yeah, don't use it to parse your Roman empire timeline, bestie. โ ๏ธ
๐ BUGS ๐
- Both the
%eand%lformat specifiers may incorrectly scan one too many digits if the intended values comprise only a single digit and that digit is followed immediately by another digit. ๐ญ - Both specifiers accept zero-padded values, even though they are both defined as taking unpadded values. The audacity. ๐
- The
%pformat specifier has no effect unless it is parsed after hour-related specifiers. Specifying%lwithout%pwill produce undefined results. โ ๏ธ Note that 12AM (ante meridiem) is taken as midnight and 12PM (post meridiem) is taken as noon. - The
%Zformat specifier only accepts time zone abbreviations of the local time zone, and the values"GMT","UTC", or"Z". This limitation is because of ambiguity due to the overloading of time zone abbreviations. One such example isESTwhich is both Eastern Standard Time and Eastern Australia Summer Time. ๐ตโ๐ซ - The
strptime()function does not correctly handle multibyte characters in theformatargument. That's the tea. ๐ต
๐ซถ That's the footer, bestie: Debian, December 9, 2024, and STRPTIME(3). We're done โ go parse something cute. ๐
๐ฆ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 1997 Joerg Wunsch
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms