TimeStamp is part of SM?
David T. Lewis
lewis at mail.msen.com
Sat Dec 21 15:12:49 UTC 2002
On Fri, Dec 20, 2002 at 08:59:27PM +0100, tblanchard at mac.com wrote:
> Actually, I'm trying to add support for a web app and want ISO-8601
> read/write support.
> 1997-12-17 07:37:16-08 - so the timezone is just specified as an offset
> [+-]hh:mm
>
> I'm having trouble figuring out how to do this with the package (which
> looks good BTW).
Your local time zone is represented by
"TimeZoneDatabase systemDatabase defaultTimeZone"
or "LocalTimeTransform here"
The names of all time zones in your database are
"TimeZoneDatabase systemDatabase timeZoneNames"
On my system, there are three timezone definitions available for Amsterdam:
"TimeZoneDatabase systemDatabase timeZoneNames
select: [:tz | '*Amst*' match: tz]"
For your purposes, the time zone for Amsterdam is represented by
"TimeZoneDatabase systemDatabase timeZoneFor: 'Europe/Amsterdam'"
The current offset in seconds from UTC in Amsterdam is
"TimeZoneDatabase systemDatabase
offsetFor: 'Europe/Amsterdam'
at: PointInTime now"
The current offset in seconds from UTC for your local time zone is
"TimeZoneDatabase systemDatabase
offsetFor: TimeZoneDatabase defaultLocation
at: PointInTime now"
There is a database entry for the 'UTC' time zone, and its current offset is zero
"TimeZoneDatabase systemDatabase
offsetFor: 'UTC'
at: PointInTime now"
I did not write any methods to do ISO 8601 formatting. If you do this, I would
suggest putting them in the "converting" method category of class PointInTime,
perhaps something like PointInTime>>asISO8601String.
See the class comment for PointInTime to see how "time" is being represented
(it's fundamentally different from the base Time and Date classes). The class
comments for LocalTimeTransform, TimeZoneRuleSet, and TimeZoneDatabase will
hopefully provide a good explanation of how the rest of this mess works.
Note that I did this stuff before the TimeStamp classes existed (I think). I have
not checked to see if there are any conflicts.
Patches for ISO 8601 formatting and/or merging with TimeStamp classes are
welcome. Feel free to update the swiki page directly.
HTH,
Dave
More information about the Squeak-dev
mailing list
|