Following up to my post last month about broken strftime(3), here is a
patch that implements all the remaining missing functionality required by
POSIX, as well as improving the documentation.
Note that there are still some useful non-POSIX extensions out there that
might be worth implementing. In glibc, strftime(NULL, (size_t)UINT_MAX,
format, &tm) returns the number of characters that would be placed into a
non-NULL string, great for allocating a string to have exact length. And
in Solaris, strftime(s, len, NULL, &tm) uses "%c" as the default format.
Also, something I did not know how to fix - POSIX requires that <time.h>
include extern int daylight, extern long timezone, and extern char
*tzname. But as currently written, <time.h> has daylight and tzname
exposed only under __CYGWIN__, and timezone is a function instead of a
long unless timezonevar is defined.
2005-02-14 Eric Blake <ebb9@byu.net>
* libc/time/time.tex: Improve the documentation.
* libc/time/strftime.c: Improve the documentation.
(iso_year_adjust): New helper function.
(strftime): Simplify '%E' and '%O'. Change '%c' to use
recursion. Fix '%C', '%y', and '%Y' to deal with years with more
than 4 characters. Combine '%d' and '%e'. Implement '%D', '%F',
'%g', '%G', '%n', '%R', '%t', '%T', '%u', '%V', '%X', and '%z'.
Avoid core dumps on valid inputs (maxsize == 0, or
tim_p->tm_isdst > 1).