VASmalltalk – ICU: working with time zones

To get a first impression here are some code examples:

// create a special calendar with a time zone and a country information
localCalendar := UCalendar 
                          openDefaultWithLocale: 'de_DE'
                          timezone: 'Europe/Berlin'.

// localCalendar now contains the local time binded to 
// the timezone and country time -> and we convert it 
// to an instance of the standard Smalltalk DateAndTime 
// class
aDateAndTime := localCalendar asDateAndTime

// aCalendar must be closed!

aCalendar close.

To get a default initialized calendar object with the timezone information retrieved from the operating system you simply type (though the current locale is not calculated right now – only the timezone is set right now):

UCalendar openDefaultWithDefaultLocaleAndTimezone

You want to get all known timezones ?

UCalendar allTimeZones

and you get a collection with 616 entries.

You want to get all known timezones for a country ?

UCalendar allCountryTimeZonesFor: 'DE'

and you get a collection with one entry: ‘Europe/Berlin’ and for ‘US’ you get 53 known timezones names.
By the way: you may also use #dbAllCountryTimeZonesFor: and #dbAllTimeZones and you the list as above but now with instances of DBString.

What is the effect/offset in daylight saving for Berlin in milliseconds ?

UCalendar getDSTSavings: 'Europe/Berlin'

What is the default time zone name for me here in Germany?

UCalendar getDefaultTimeZone

which by the way returns “Europe/Budapest” and not “Europe/Berlin”, but the offset is identical.

What locales are allowed for instances of UCalendar?

UCalendar availableLocales

which returns a collection of 435 locales.

This entry was posted in Smalltalk and tagged . Bookmark the permalink.

2 Responses to VASmalltalk – ICU: working with time zones

  1. Hello Martin,

    Great idea to use this library for internationalization in VA Smalltalk. Can you tell us which DLL’s are required to run the code. Is ‘icuuc46.dll’ enough or are more files needed.

    Jan.

    • schrievkrom says:

      They are mostly needed, though only two libraries are directly needed “icuin46.dll” and “icuuc46.dll” – but I guess, they will load the others – especially the large one with the database.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s