[Zope3-dev] Time zone use case
Wade Leftwich
wade@wvmm.net
Thu, 14 Mar 2002 07:34:44 -0500
On Wednesday 13 March 2002 19:06, Tim Peters wrote:
> [Wade Leftwich]
> > [snip]
> > - Collect reports from a number of branch offices.
> > - Each report has a local date and time, and a Windows time zone.
> > - Store reports with a UTC timestamp added, so they can be sorted
> > by "actual" date and time
> [snip]
> Could you elaborate on what "Windows time zone" means? =A0I've been usi=
ng
> Windows for years, and don't recall ever seeing one except when setting=
the
> clock for the first time. =A0Is it, e.g., one or more of
>
> - A 3-character symbolic name (EST, CDT)?
> - A long name (Eastern, U.S. Central)?
> - A signed offset from UTC? =A0(-0500)?
>
> Show us some real examples, please, and/or point to a spec.
I guess by "Windows time zone" I meant that list of choices you see when =
you=20
set the clock for the first time. I did a bit of searching, and found no=20
Windows-specific documentation.
I did find something useful, though:=20
http://greenwichmeantime.com/info/timezone.htm
and
http://greenwichmeantime.com/info/timezone-summer.htm
(at least the domain name sounds authoritative).
These pages list the offsets from GMT, letter (military and aviation)=20
designations and familiar civilian abbreviations, for example
-0 Z GMT, UTC, UT, WET
-5 R EST
-4 EDT (note no military equivalent)
+12 M IDLE, NZST (International Date Line East, New Zealand Standard Time=
)
I think it would be reasonable to accept any of these three forms, but no=
t to=20
bother with long names.
(By the way, I also tried the U.S. Naval Observatory=20
(http://tycho.usno.navy.mil), but they only seem to care about U.S. time=20
zones.)
>
> In addition, are you expected some canned way to parse whatever "local =
date
> and time" strings Windows produces? =A0In multiple languages? =A0Etc.
Yes, using format strings. Some kind of "best guess" would be nice too, a=
la=20
mxDateTime.Parser
I would be comfortable with applying timezone conversions separately from=
=20
parsing local-time strings.
parse(LocalDateTimeString, FormatString) =3D> NaiveDateTimeObject
getTimeZone(LocalDateTimeString, FormatString, Default) =3D> OffsetFromGM=
T
shiftTimeZone(NaiveDateTimeObject, SourceTimeZone, TargetTimeZone=3DGMT)=20
=3D>NaiveDateTimeObject in the target tz
For convenience, SourceTimeZone and TargetTimeZone args can be integers (=
GMT=20
offsets) or strings (GMT offset, military or civilian tz code).
-- Wade Leftwich
Ithaca, NY