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.
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.
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.