Examples:
In 2011, DST for the time zone named 'America/New_York' started at 2 am on Sunday March 13, and Eastern Standard Time became Eastern Daylight Time.
Time zone support allows the correct calculation of the duration between noon Saturday March 12, 2011 and noon Sunday March 13, 2011; the duration is 23 hours, not 24.
| date1 date2 |
"noon Saturday 3/12/2011"
date1 := DateAndTime year: 2011 month: 3 day: 12 hour: 12 minute: 0 second: 0.
"noon Sunday 3/13/2011"
date2 := DateAndTime year: 2011 month: 3 day: 13 hour: 12 minute: 0 second: 0.
(date2 - date1) inspect "0:23:00:00"
Similarly, adding 1 day to noon Saturday March 12, 2011, results in a time of 1 pm Sunday March 13, 2011.
| date1 date2 |
"noon Saturday 3/12/2011"
date1 := DateAndTime year: 2011 month: 3 day: 12 hour: 12 minute: 0 second: 0. "2011-03-12T12:00:00-05:00"
"add 1 day"
date2 := date1 + (Duration days: 1).
date2 inspect "2011-03-13T13:00:00-04:00"
Using time zone information, it is possible to create a DateAndTime object in a specific time zone, and then transform that DateAndTime object to one in another time zone. Continuing with March 12, 2011, the day before the US transitioned to DST.
| date1 date2 |
"11:30 pm in Los Angeles on March 12, 2011"
date1 := DateAndTime year: 2011 month: 3 day: 12 hour: 23 minute: 30 second: 0 timeZone: 'America/Los_Angeles'.
date2 := date1 transformToTimeZoneNamed: 'America/New_York'.
(date2 = date1) inspect "true"
 
Inspecting date1 above results in "2011-03-12T23:30:00-08:00"; date2 is "2011-03-13T03:30:00-04:00". The difference in offset is 4 hours instead of the usual 3, because DST is already in effect in New York but not yet in Los Angeles. The two DateAndTime objects are the same time in that they both are 3477454200000 milliseconds. Only their time zones are different.
 
Last modified date: 01/29/2015