Re: clock format and timezones
From: Mike Tuxford (tuxfordNOSPAM_at_NORETURNearthlink.net)
Date: 04/16/04
- Next message: Gerald W. Lester: "Call For Papers (CFP) -- 11th Tcl/Tk Conference"
- Previous message: Cameron Laird: "Re: LDAP"
- In reply to: WL: "clock format and timezones"
- Next in thread: Kevin Kenny: "Re: clock format and timezones"
- Reply: Kevin Kenny: "Re: clock format and timezones"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 15 Apr 2004 23:02:42 GMT
WL <me@privacy.net> wrote:
:I'm trying to output some timestamps according to specific
:timezones. I tried using the -gmt flag, but it doesn't seem
:to make a difference. This is on netbsd/alpha with tcl 8.4.2
:via tclkit.
...
Well, continuosuly changing the system timezone might be
one way to approach the problem but I'd rather create a unix
timestamp based on a relative offset from GMT.
array set tz {
UTC +0 GMT +0 BST +1 IST +1 WET +0 WEST +1
CET +1 CEST +2 EET +2 EEST +3 MSK +3 MSD +4
AST -4 ADT -3 EST -5 EDT -4 CST -6 CDT -5
MST -7 MDT -6 PST -8 PDT -7 HST -10 AKST -9
AKDT -8 AEST +10 AEDT +11 AWST +8 ACST +9.5
Y -12 X -11 W -10 V -9 U -8 T -7 S -6 R -5
Q -4 P -3 O -2 N -1 Z 0 A +1 B +2 C +3 D +4
E +5 F +6 G +7 H +8 I +9 K +10 L +11 M +12
}
if {[llength $argv] == 0 || \
![info exists tz([string toupper \
[lindex $argv 0]])]} {
puts "Syntax: tz <timezone>"
exit
}
# calsulate the time offset
set os [expr round($tz([string toupper \
[lindex $argv 0]])*3600)]
# calculate the unix timestamp
set ts [expr {[clock scan "now" -base \
[clock seconds] -gmt 1]+$os}]
# output our local time
puts " here: [clock format [clock seconds] \
-format "%c %Z" -gmt 0]"
# output the other timezone
puts "there: [clock format $ts -format \
"%c [lindex $argv 0]" -gmt 1]"
-- _ _ ____ //\/\ike ||uxford tuxford@earthlink.net
- Next message: Gerald W. Lester: "Call For Papers (CFP) -- 11th Tcl/Tk Conference"
- Previous message: Cameron Laird: "Re: LDAP"
- In reply to: WL: "clock format and timezones"
- Next in thread: Kevin Kenny: "Re: clock format and timezones"
- Reply: Kevin Kenny: "Re: clock format and timezones"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|