Date: Fri, 28 Oct 2022 16:56:19 -0500 From: Stephen Montgomery-Smith <montgomerysmithstephen@gmail.com> To: Thomas Mueller <tmueller@sysgo.com>, Warner Losh <imp@bsdimp.com> Cc: freebsd-hackers <freebsd-hackers@freebsd.org> Subject: Re: Equivalent of Linux timezone in FreeBSD Message-ID: <dae8b22a-26dc-26ba-6bb5-55e9e9633a56@FreeBSD.org> In-Reply-To: <6610316d-7ebf-f914-4276-3add9fd74dea@FreeBSD.org> References: <f8db389b-a882-13c4-bfc5-9cd1c56762ca@FreeBSD.org> <CANCZdfpntEyQFg2qc8qkn=54JHHKtt43rSGf%2Bo=x4UK=4Z6sjQ@mail.gmail.com> <20221028075511.554f12c8@tmu.ulm.sysgo.com> <6610316d-7ebf-f914-4276-3add9fd74dea@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On 10/28/22 16:34, Stephen Montgomery-Smith wrote: > On 10/28/22 00:55, Thomas Mueller wrote: >> On Thu, 27 Oct 2022 13:32:55 -0600, Warner Losh wrote: >>> On Thu, Oct 27, 2022 at 1:26 PM Stephen Montgomery-Smith < >>> montgomerysmithstephen@gmail.com> wrote: >>> >>>> I am attempting to port code that uses an external variable called >>>> timezone, which is defined in the Linux file time.h as the number of >>>> seconds West of UTC for the current timezone. >>> > >> >> The timezone variable is part of the POSIX XSI option (X/Open System >> Interfaces). As mentioned in the original post it contains the number >> of seconds West of UTC for the current timezone. >> >> Excerpt from the standard text for tzset(): >> #include <time.h> >> [XSI] extern int daylight; >> extern long timezone; >> [CX] extern char *tzname[2]; >> void tzset(void); >> [...] >> [XSI] The tzset() function also shall set the external variable >> daylight to 0 if Daylight Savings Time conversions should >> never be >> applied for the timezone in use; otherwise, non-zero. The >> external >> variable timezone shall be set to the difference, in seconds, >> between >> Coordinated Universal Time (UTC) and local standard time. >> >> I suppose FreeBSD's tm_gmtoff field in "struct tm" is an equivalent. >> > > Excellent. I replaced timezone with localtime(0)->tm_gmtoff. > > Thank you very much. Oops, I meant localtime(&zero)->tm_gmtoff, where zero is of type time_t.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?dae8b22a-26dc-26ba-6bb5-55e9e9633a56>