[tz] [PROPOSED 2/2] strftime: conform better to POSIX+

Robert Elz kre at munnari.OZ.AU
Mon Aug 10 07:58:41 UTC 2020

    Date:        Sun, 9 Aug 2020 11:00:35 -0700
    From:        Paul Eggert <eggert at cs.ucla.edu>
    Message-ID:  <35abe9d1-18c3-dd9b-cd6b-5d46866f66df at cs.ucla.edu>

  | I installed the attached patch to do it.

The only comment I'd make about that, and this is just style, is that
instead of ...

  | +	timeout(stdout, format ? format : "+%+", tmp);

we simply init format before (actually during) the arg processing, as ...

	format = "+%a %b %e %H:%M:%S %Z %Y";

(other than the leading '+' (which could be a space there, or other)
the content of the string isn't important here).

and then allow a '+' arg to override it.   There's actually a bit more
to the arg processing than I showed, but nothing important for this issue.

  | General-purpose  routines don't always have the luxury of knowing that
  | format[-1] is available.

No, they don't, but someone designing a general purpose routine to
use strftime (or for that matter, anything) should design it around
the characteristics of strftime (or whatever).   Do it with that in
mind, and whatever extra needs doing to handle strftime (etc) properly
becomes much easier, than if one ignores the properties of the
interfaces to be used to implement the routine, and has to coerce a
poorly designed API to fit.


ps: to get the ERANGE accepted by posix, it needs to be the standard
(or at least common) behaviour first, POSIX specifies what the standard
is, it doesn't (usually anyway) invent it (or adopt someone else's
invention).   It is very rare for something to be added which would make
a formerly conforming implementation become non-conforming.

More information about the tz mailing list