Re: clock format and timezones

From: Mike Tuxford (tuxfordNOSPAM_at_NORETURNearthlink.net)
Date: 04/16/04


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


Relevant Pages

  • Re: Python 2.5.1 broken os.stat module
    ... |>> when DST starts and also when DST ends, even though the file has NOT ... Windows is not claiming ... | That local textual representation of the modification timestamp is what ... And without a timezone attached, ...
    (comp.lang.python)
  • Re: question about GMT and UTC
    ... I need a timezone to store timestamps in that is independent of daylight saving. ... it seems I want either GMT or UTC. ... Could someone please confirm if they are in fact the same or if one is better, and if I am correct in stating that neither is affected by daylight saving? ... for example, will always return the exact same timestamp in either GMT or UTC timezone and vice versa, i.e. 1 timestamp resulting in the exact same 12:00:00 readout via datewhether GMT or UTC. ...
    (comp.lang.php)
  • Re: how to make dates without timezones?
    ... class, with a unique format on the wire, so that you don't accidentally ... seems to me that there should be a strictly CalendarDate class i could ... use for the date types and CalendarTimeStamp class for the timestamp ... after on a change in timezone. ...
    (comp.lang.java.programmer)
  • Re: Email TimeStamp
    ... that should be able to tell you where the timestamp is wrong... ... Susan Conkey [MVP] ... I verified the server has the correct time and timezone ...
    (microsoft.public.exchange.admin)
  • Time zone offset and daylight saving
    ... I don't seem to be able to correctly calculate the time offset between ... two time zones when daylight saving is in effect. ... on me actually being in that timezone. ... # Compute the time offset between two timezones (UTC and PST) ...
    (comp.lang.ruby)