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 00:03:10
On Sun, Feb 26, 2006 at 06:10:16PM -0500, George Georgalis wrote:
> Right, but that's not what I meant to ask for. I meant, in a
> specified timezone (specifically -0200), what are the unix
> seconds at the start of the present day (second zero), in linux
> that would be "date -d 0" for any given TZ or print format you
> set.
if you say so. Of course the man page for linux's date program
doens't specify at all what -d expects. It certainly doesn't match
up with the normal input format, which would require "00000000".
well, anyway, NetBSD doesn't have anything resembling linux's -d option.
It would be useful though.
> What I'm trying to do is generate Swatch internet beat time
> (the same numeral 000 through 999, everywhere in the world,
> cycling every 24 hours, synchronized from Biel, Switzerland),
> in netbsd ksh.
>
> This works in Linux bash (tm):
>
> echo @$((10*(`TZ='GMT-1' date +%s`-`TZ='GMT-1' date -d 0 +%s`)/864))
>
> that's integer math, ten times the difference of unix seconds in
> Biel, at the zero second, of today, there, divided by (mod) 864.
>
> It's not clear how I may determine unix seconds for the zero
> second of the present day, in a given timezone, with netbsd.
Well, don't bother with that. Just do this:
TZ='GMT-1' date +"%H 60 * %M + 60 * %S + 10 * 864 / p" | dc
eric