Subject: Re: TZ and unix epoc
To: None <tech-kern@NetBSD.org>
From: Eric Haszlakiewicz <erh@nimenees.com>
List: tech-kern
Date: 02/26/2006 13:17:14
On Sun, Feb 26, 2006 at 12:30:09PM -0500, George Georgalis wrote:
>
> I expected this command to return unix seconds of
> Thu Jan 1 00:00:00 GMT-2 1970; but it returns 0.
>
> env TZ='Etc/GMT-2' date -r 0 +%s
>
> question 1, is this a bug?
You asked for 0 seconds from the Epoch. You got 0 seconds from the Epoch.
That sounds about right to me.
> question 2, how do I get the desired unix seconds?
I'm guessing you're trying to get the number of seconds between
two time zones. That depends on what the date and time actually is, because
of things like some timezones having daylight savings time, and others don't.
You can get the offset for the _current_ (approximate) moment by comparing:
env TZ='tz#1' date +%z
env TZ='tz#2' date +%z
but of course you'll need to parse out the hours and minutes and calculate
the seconds yourself.
eric