Subject: Re: TZ and unix epoc
To: tech-kern@NetBSD.org, George Georgalis <george@galis.org>
From: Chapman Flack <nblists@anastigmatix.net>
List: tech-kern
Date: 02/27/2006 12:58:09
> 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.
I may not have noticed this thread early enough to be sure exactly
what you want to do, but if using ksh is an option (not pdksh), is
this close to what you want? (I am in Eastern Std. Time)
$ printf $'%(%s)T\n' today
1141016400
$ printf $'%(%s)T\n' 'today EST'
1141016400
$ printf $'%(%s)T\n' 'today GMT'
1140998400
$ printf $'%(%s)T\n' 'today GMT-0200'
1141005600
$ printf $'%T\n' '#1141016400'
Mon Feb 27 00:00:00 EST 2006
Because it only uses printf, a ksh builtin, it may be a smidge
faster than solutions that fork date, dc, etc.
-Chap