Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 27 Oct 2022 13:32:55 -0600
From:      Warner Losh <imp@bsdimp.com>
To:        Stephen Montgomery-Smith <montgomerysmithstephen@gmail.com>
Cc:        freebsd-hackers <freebsd-hackers@freebsd.org>
Subject:   Re: Equivalent of Linux timezone in FreeBSD
Message-ID:  <CANCZdfpntEyQFg2qc8qkn=54JHHKtt43rSGf%2Bo=x4UK=4Z6sjQ@mail.gmail.com>
In-Reply-To: <f8db389b-a882-13c4-bfc5-9cd1c56762ca@FreeBSD.org>
References:  <f8db389b-a882-13c4-bfc5-9cd1c56762ca@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
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.
>

Except it's not completely reliable on linux, since it's not a constant
except for
the few minutes around the current time.... You can't expect it to work
around the
cut-overs of daylight savings time, for example.


> Is there an equivalent of this in FreeBSD or other BSDs?
>

getenv("TZ") will get the timezone for the current process.

But what are you using this value for?

Warner


> Is this the right group to ask this question?
>
> Thanks, Stephen
>
>

[-- Attachment #2 --]
<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Oct 27, 2022 at 1:26 PM Stephen Montgomery-Smith &lt;<a href="mailto:montgomerysmithstephen@gmail.com">montgomerysmithstephen@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I am attempting to port code that uses an external variable called <br>
timezone, which is defined in the Linux file time.h as the number of <br>
seconds West of UTC for the current timezone.<br></blockquote><div><br></div><div>Except it&#39;s not completely reliable on linux, since it&#39;s not a constant except for</div><div>the few minutes around the current time.... You can&#39;t expect it to work around the</div><div>cut-overs of daylight savings time, for example.</div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Is there an equivalent of this in FreeBSD or other BSDs?<br></blockquote><div><br></div><div>getenv(&quot;TZ&quot;) will get the timezone for the current process.</div><div><br></div><div>But what are you using this value for?</div><div><br></div><div>Warner</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Is this the right group to ask this question?<br>
<br>
Thanks, Stephen<br>
<br>
</blockquote></div></div>

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CANCZdfpntEyQFg2qc8qkn=54JHHKtt43rSGf%2Bo=x4UK=4Z6sjQ>