TimeZone setup, as simple as possible

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

TimeZone setup, as simple as possible

Janko Mivšek
Hi,

I'm just going through the challenge to set a local timezone correctly
and I'm wondering why there is no something as simple as:

        TimeZone setLocal: 'CET'

to set my timezone?

Best regards
Janko


Reply | Threaded
Open this post in threaded view
|

Re: TimeZone setup, as simple as possible

Philippe Marschall
2007/8/21, Janko Mivšek <[hidden email]>:
> Hi,
>
> I'm just going through the challenge to set a local timezone correctly
> and I'm wondering why there is no something as simple as:
>
>         TimeZone setLocal: 'CET'
>
> to set my timezone?

With Chronos you can use:
(Timezone at: #'CET') beSystem

Cheers
Philippe


Reply | Threaded
Open this post in threaded view
|

Re: TimeZone setup, as simple as possible

Janko Mivšek
Hi Philippe,

Philippe Marschall wrote:

>> I'm just going through the challenge to set a local timezone correctly
>> and I'm wondering why there is no something as simple as:
>>
>>         TimeZone setLocal: 'CET'
>>
>> to set my timezone?
>
> With Chronos you can use:
> (Timezone at: #'CET') beSystem

That's better, but you need to load Chronos. Question is, wouldn't be
fine if something like that would be in a default squeak image?

Janko


Reply | Threaded
Open this post in threaded view
|

Re: TimeZone setup, as simple as possible

Brent Pinkney-2
In reply to this post by Philippe Marschall
Hi,

> 2007/8/21, Janko Mivšek <[hidden email]>:
> > Hi,
> >
> > I'm just going through the challenge to set a local timezone correctly and I'm wondering why there is no something as simple as:
>
>   TimeZone setLocal: 'CET'
>

There is.

The standard DateAndTime implementation in the image has #localTimeZone:

I for example use:

        sast := TimeZone timeZones fourth.
        sast offset. " 0:02:00:00 - always two hours ahead"

        DateAndTime localTimeZone: sast.

        DateAndTime now. "2007-08-21T22:47:04+02:00 - as it should be"




Of course, the IDE would have told you this by browsing all references to class TimeZone - it is the first result.


Regards


Brent

Reply | Threaded
Open this post in threaded view
|

Re: TimeZone setup, as simple as possible

Philippe Marschall
In reply to this post by Janko Mivšek
2007/8/21, Janko Mivšek <[hidden email]>:

> Hi Philippe,
>
> Philippe Marschall wrote:
>
> >> I'm just going through the challenge to set a local timezone correctly
> >> and I'm wondering why there is no something as simple as:
> >>
> >>         TimeZone setLocal: 'CET'
> >>
> >> to set my timezone?
> >
> > With Chronos you can use:
> > (Timezone at: #'CET') beSystem
>
> That's better, but you need to load Chronos.
Yeah, packages must be loaded like Swazoo or SPort.

> Question is, wouldn't be
> fine if something like that would be in a default squeak image?

You mean like setting the locale to the correct value?

http://www.chronos-st.org/Discovering%20the%20Local%20Time%20Zone--Why%20It's%20a%20Hard%20Problem.html

Cheers
Philippe


Reply | Threaded
Open this post in threaded view
|

Re: TimeZone setup, as simple as possible

Janko Mivšek


Philippe Marschall wrote:

>>>> I'm just going through the challenge to set a local timezone correctly
>>>> and I'm wondering why there is no something as simple as:
>>>>
>>>>         TimeZone setLocal: 'CET'
>>>>
>>>> to set my timezone?
>>> With Chronos you can use:
>>> (Timezone at: #'CET') beSystem
>> That's better, but you need to load Chronos.
>
> Yeah, packages must be loaded like Swazoo or SPort.

Sure, but TimeZone is already there and what is missing is one or two
additional methods which will ease timezone setup.

One simple method! Why is that obviously so hard to do? Smalltalk is
famous because it grown out of simple but consistent implementation of
few basic ideas, why wouldn't we continue that tradition in such a small
case as is this timezone setup?

Janko

>
>> Question is, wouldn't be
>> fine if something like that would be in a default squeak image?
>
> You mean like setting the locale to the correct value?
>
> http://www.chronos-st.org/Discovering%20the%20Local%20Time%20Zone--Why%20It's%20a%20Hard%20Problem.html
>
> Cheers
> Philippe
>
>
> ------------------------------------------------------------------------
>
>

--
Janko Mivšek
AIDA/Web
Smalltalk Web Application Server
http://www.aidaweb.si

Reply | Threaded
Open this post in threaded view
|

Re: TimeZone setup, as simple as possible

David T. Lewis
In reply to this post by Janko Mivšek
On Tue, Aug 21, 2007 at 12:23:54PM +0200, Janko Miv??ek wrote:
> Hi,
>
> I'm just going through the challenge to set a local timezone correctly
> and I'm wondering why there is no something as simple as:
>
> TimeZone setLocal: 'CET'
>
> to set my timezone?

Janko,

That is a very good idea, thanks for the suggestion. I added #setLocal:
to the TimeZoneDatabase package so you be able to do this.

Squeak does not use time zone tables, nor does it query the operating
system for this information. This works well enough for most users,
and it is very simple, which is a good thing.

If you want to have correct time zone information, you can load either
Chronos or TimeZoneDatabase from SqueakMap, and this will be added.

I added your #setLocal: method to the TimeZoneDatabase package, so if
you update your SqueakMap and load TimeZoneDatabase into your image,
you will be able to evaluate "TimeZone setLocal: 'CET'".

Dave