This is the mail archive of the gnats-devel@sources.redhat.com mailing list for the GNATS project.


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

Re: gnats devel FW: New time zones



 >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


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