Re: Equivalent of Linux timezone in FreeBSD

From: Stephen Montgomery-Smith <montgomerysmithstephen_at_gmail.com>
Date: Fri, 28 Oct 2022 21:34:36 UTC
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.