tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: strftime(3) oddities with %s, %z



    Date:        Wed, 26 Oct 2022 09:40:24 -0400 (EDT)
    From:        Mouse <mouse%Rodents-Montreal.ORG@localhost>
    Message-ID:  <202210261340.JAA25733%Stone.Rodents-Montreal.ORG@localhost>


  | Yes, but it's not necessary to map it to a _correct_ value.

For the uses I mentioned, it isn't - but localtime() (or gmtime(), the
same problem exists there) has no idea of the use that will be made of
the resulting struct.   They need to be accurate, or indicate an error,
not simply perform value substitution because it happens to be convenient.

  | For those
  | purposes, it would be enough to convert anything out of range to, say,
  | (proleptic) Gregorian year 9999, or 1000000, or some such.

And so that would need to be done by bounding the time_t being passed
in, as the caller knows when some random huge time is OK when the value
is huge (+ or -) rather than the correct one being required.

  | [....]  I don't see any good way to reconcile these.

Welcome to the wonderful world of computing time...   What seems to be
the simplest of measurements is in fact by far the most complex, and the
least understood.

kre



Home | Main Index | Thread Index | Old Index