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):
You want to get all known timezones ?
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?
which by the way returns “Europe/Budapest” and not “Europe/Berlin”, but the offset is identical.
What locales are allowed for instances of UCalendar?
which returns a collection of 435 locales.