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
--000000000000ec342605ec093583
Content-Type: text/plain; charset="UTF-8"

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
>
>

--000000000000ec342605ec093583
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"><br></div><br><div class=3D"gmail_quote">=
<div dir=3D"ltr" class=3D"gmail_attr">On Thu, Oct 27, 2022 at 1:26 PM Steph=
en Montgomery-Smith &lt;<a href=3D"mailto:montgomerysmithstephen@gmail.com"=
>montgomerysmithstephen@gmail.com</a>&gt; wrote:<br></div><blockquote class=
=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rg=
b(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></di=
v><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 dayligh=
t savings time, for example.</div><div>=C2=A0<br></div><blockquote class=3D=
"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(2=
04,204,204);padding-left:1ex">
Is there an equivalent of this in FreeBSD or other BSDs?<br></blockquote><d=
iv><br></div><div>getenv(&quot;TZ&quot;) will get the timezone for the curr=
ent process.</div><div><br></div><div>But what are you using this value for=
?</div><div><br></div><div>Warner</div><div>=C2=A0</div><blockquote class=
=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rg=
b(204,204,204);padding-left:1ex">
Is this the right group to ask this question?<br>
<br>
Thanks, Stephen<br>
<br>
</blockquote></div></div>

--000000000000ec342605ec093583--



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