public inbox for gnats-devel@sourceware.org
 help / color / mirror / Atom feed
* Re: gnats devel FW: New time zones
@ 2001-05-24 14:06 Carl E. Lindberg
  2001-05-26 13:36 ` Milan Zamazal
  0 siblings, 1 reply; 2+ messages in thread
From: Carl E. Lindberg @ 2001-05-24 14:06 UTC (permalink / raw)
  To: gnats-devel

 >I typically build-my-own %z equivalent out of using the same reference
 >time and passing it to both localtime() and gmtime() converting back
 >to seconds

	Yup, that's the basic approach.  I've found though that it's 
problematic to use mktime() to convert back to seconds, as some of the 
sytems that have the tm_gmtoff field use it inside mktime(), so the two 
conversions would end up at the same seconds value.  My code just

 > and then doing the subtraction to get the offset in seconds
 >and dividing by 36 to get 'hours' in hundreds.

	Careful -- many localities are offset X-hours-and-a-half from UTC, 
and in those cases the offsets should be like +0430 (dividing by 36 
would get you +0450).  You need to split out the hours and minutes 
values to do it right.

	[There's even a couple of places that are 45 minutes offset -- 
Nepal and an island somewhere near New Zealand I think.]


 >For what it is worth, the %z format was introduced to FreeBSD 4.0 in
 >that lib/libc/stdtime/strftime.c in version 1.25 of the file which was
 >in FreeBSD 4.0 and subsequent releases contains the patch to support it.

	Cool, that's good to know.

 >My recommendation would be to use a configure test for the %z format
 >and then use strftime() if it works or use a compatibility package if
 >it does not.

	Probably the best idea.  I'm sure my code would work the same even 
on those platforms, but it's better to use the system-provided 
implementations if at all possible.

	-Carl

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: gnats devel FW: New time zones
  2001-05-24 14:06 gnats devel FW: New time zones Carl E. Lindberg
@ 2001-05-26 13:36 ` Milan Zamazal
  0 siblings, 0 replies; 2+ messages in thread
From: Milan Zamazal @ 2001-05-26 13:36 UTC (permalink / raw)
  To: Carl E. Lindberg; +Cc: gnats-devel

Thanks, Carl and Dirk, for the clarification regarding the time zones,
it was really needed.

As for %z in strftime, GNU libc says it's part of ISO C99.  I don't know
what ISO C99 is, but I expect it means %z becomes a generally available
feature.  So I added an autoconf test for it, and if the feature is
unavailable I simply replace all %z's by %Z.  I think this is a fair
approach -- it's not worse than the current situation at least.

Regards,

Milan Zamazal

-- 
Wasting somebody else's time strikes me as the height of rudeness.
						      Bill Gates

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-05-26 13:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-24 14:06 gnats devel FW: New time zones Carl E. Lindberg
2001-05-26 13:36 ` Milan Zamazal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).