Time zone definitions
Mark Koennecke
Mark.Koennecke at psi.ch
Thu Jan 6 07:28:42 GMT 2000
On Wed, 5 Jan 2000, Ray Osborn wrote:
> A question for the C experts. When I was trying to get the time zone set
> correctly using the Metrowerks CodeWarrior compiler on the Mac, I found that
> tm_gmtoff is not included in the Mac's tm struct. However, as you can see
> in the version of NAPI.C that I committed to the server yesterday (search
> for the __MWERKS__ ifdef), I was able to get around the problem by using the
> time difference between the gmtime and localtime functions.
>
> I'm not absolutely sure about this because I don't have the ANSI C (or ISO
> C) standard in front of me, but this web site seems to confirm this. If
> that's the case, isn't it safer to use the technique I have defined as the
> default technique, and only use the ifdefs for the pathological non-ANSI
> cases (e.g. DEC C v5)?
>
> I presume that the tm_gmtoff is a GNU C extension to the ANSI C standard.
> Is that right?
>
> Any thoughts?
> Ray
Ray,
I looked into my copy of the Kernighan & Ritchie which contains a fairly
complete rendition of the ANSI-C standard. You seem to be right that
tm_gmtoff is NOT required by ANSI-C. Whereas gmtime and localtime is. I
then looked at my time.h on DigitalUnix and found that the tm_gmtoff is
ifdef'ed with _OSF_SOURCE. This suggests to me that it may be in the
POSIX-standard. Anyway, I suggest to go with the gmtime-localtime option
for more portability.
Mark
More information about the NeXus-developers
mailing list