This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ssmtp "Date:" oddity

Igor Pechtchanski wrote:
> On Mon, 2 Feb 2004, Robert R Schneck wrote:
> > Maybe someone can help me understand this.  The problem is in the
> > following format string to strftime:
> >
> >         /* RFC822 format string borrowed from GNU shellutils date.c */
> >         const char *format = "%a, %_d %b %Y %H:%M:%S %z";
> >
> >         now = time(NULL);
> >         date = localtime((const time_t *)&now);
> >         (void)strftime(d_string, ARPADATE_LENGTH, format, date);
> >
> > Both %_ and %z become nothing.
> Most likely the latter.  Cygwin gets its strftime implementation from
> newlib, which understands neither of the two format strings above.
> IIUC, "%_d" is intended to produce the day of the month preceded by a
> blank if single-digit.  In newlib and all other systems I could access
> this is accomplished via the "%e" strftime format string.  I couldn't even
> find "%_d" until I looked at "date --help", and found out that "date" uses
> the underscore ("_") to indicate space padding (although the newer GNU
> versions also support "%e" for space-padded day).  It is my guess that
> "%_d" is a typo and should be fixed.
> "%z" is a harder case, since some systems (Darwin, Linux) do understand
> it, and some (newlib, Solaris, BSD) don't.  The Linux man page lists "%z"
> as a GNU extension.  I would guess newlib would be happy to support it
> given a patch, since it is (to quote the Linux man page) "required to
> emit RFC822-conformant dates", but it's their call.

Yes, those are both GNU extensions, see

However, the page does mention that "%z" is supposed to be in C99.  But
I can echo a story of heartburn and hair pulling trying to figure out
why it didn't work under FreeBSD.  It my case it was actually
strptime(), but its manpage says that it supports all the format
specifiers of strftime.  Insidiously, the FreeBSD manpage for
strftime(3) lists support for %z.  But there's no support for it in
strptime.  I finally rooted around in CVS to find the darn source for
that function:
...At which point I discovered the error in their manpage.  I then began
on a trek to get their stupid 'send-pr' thing to work to report it. 
They ONLY accept pr's through email, but their mail server is picky in
whom it will talk to -- my FreeBSD server had no reverse DNS at the
time, and of course you can't run send-pr on any other kind of system. 
So after doing all that I finally found that this had been reported
before in their pr database, likely by other really PO'd people that had
wasted hours and hours on this stupid issue that could be fixed by
adding a single sentence to a manpage.  And yet to this day it's still
not fixed, so I'm sure others are having this same issue if they want to
use %z in their code.  *BIG SIGH*  Not bitter, I swear...


Unsubscribe info:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]