.Dd July 8, 2010 .Dt LIBPARSEDATE 3 .Os NetBSD 1.4T .Sh NAME .Nm parsedate .Nd date/time parsing routine .Sh SYNOPSIS .Fd #include .br .Nm cc .Op Ar arguments .Fl lparsedate .br .Ft time_t .Fn parsedate "const char *string" .Ft time_t .Fn parsedate_ext "const char *string" "unsigned int exts" "..." .Sh DESCRIPTION .Fn parsedate is designed to parse a string representing a date and time, such as one might find in email headers or typed by a user, and return the corresponding time in system time format (such as might be returned by .Xr time 3 ) . .Pp On error, the return value is .Li (time_t)-1 Ns No . There is no way to distinguish this from a successful parse of a string that specifies that time. .Pp .Fn parsedate_ext is similar, but supports various extensions. The .Fa exts argument is a bitmask of extensions; some of the possible extensions indicate that additional arguments are supplied as well. If multiple extension bits specify additional arguments, the additional arguments appear in the order the in which their controlling bits are listed here. .Pp The supported extension bits are: .Bl -tag -width indent .It PARSEDATE_EXT_ALLOWFRAC Fractional seconds are allowed. Everywhere a seconds value may appear, it may have an appended .Sq \&. and a decimal fraction. By itself, this flag does not do anything with the fractional part; it merely modifies the accepted syntax. See .Dv PARSEDATE_EXT_STOREFRAC for how to do something useful with the fraction. .It PARSEDATE_EXT_STOREFRAC Takes one additional argument, of type .\" .Fa is semantically wrong here, but I don't see anything that's .\" both righter and working. .Ft looks semantically close to right, .\" but .\" .Ft int * . .\" and .\" .Ft "int *" . .\" both mishandle the trailing punctuation. .Fa "int *" . If a fractional part is present, it is stored through this argument; if no fractional part is present, zero is stored instead. (Note that .Dv PARSEDATE_EXT_ALLOWFRAC must be set as well for a fractional part to be permitted at all.) If the parse is unsuccessful, it is undefined whether the argument is stored through and, if so, what the value stored is. .El .Pp As a convenience, .Dv PARSEDATE_EXT_FRAC is defined as .Pf ( Dv PARSEDATE_EXT_ALLOWFRAC \&| PARSEDATE_EXT_STOREFRAC ) . .Sh BUGS Probably. .Sh AUTHOR Originally, Rich $alz, as part of inn-1.4. Anne Bennett .Aq anne@rodents.montreal.qc.ca took this, added some stuff (in particular, made it accept more date formats) and produced a command-line tool; then der Mouse .Aq mouse@rodents.montreal.qc.ca took that and turned it into a library routine. In 2006-04, Mouse rewrote the whole thing because the former version broke when crossing DST changeover points.