'From Squeak3.7gamma of ''17 July 2004'' [latest update: #5987] on 7 November 2004 at 1:08:12 pm'! "Change Set: DateAndTimeTest-additionalTests-2 Date: 7 November 2004 Author: David T. Lewis, Boris Gaertner When the clock on the wall in Detroit says 9:00am, the clock on the wall in London says 2:00pm. The Duration difference between the corresponding DateAndTime values should be zero. These four test cases test * the correct translation of the denotation of DataAndTime values * correct computation with DataAndTime values of different time zones. Updated to work when Squeak TimeZone is set to something other than UTC. "! !DateAndTimeTest methodsFor: 'Tests' stamp: 'dtl 11/7/2004 13:00'! testDateTimeDenotation1 "DateAndTimeTest new testDateTimeDenotation1" " Detroit is 5 hours behind UTC, this offset to UTC is therefore written with a minus sign. This example tests the correct interpretation of the DateAndTime denotation. " | twoPmInLondon twoPmUTCInLocalTimeOfDetroit nineAmInDetroit | twoPmInLondon := DateAndTime year: 2004 month: 11 day: 2 hour: 14 minute: 0 second: 0 offset: 0 hours. twoPmUTCInLocalTimeOfDetroit _ twoPmInLondon utcOffset: -5 hours. nineAmInDetroit _ '2004-11-02T09:00:00-05:00' asDateAndTime. self assert: twoPmUTCInLocalTimeOfDetroit = nineAmInDetroit. ! ! !DateAndTimeTest methodsFor: 'Tests' stamp: 'dtl 11/7/2004 13:01'! testDateTimeDenotation2 "DateAndTimeTest new testDateTimeDenotation2" " Moscow is 3 hours ahead UTC, this offset to UTC is therefore positive. This example tests the correct interpretation of the DateAndTime denotation. " | lateEveningInLondon lateEveningInLocalTimeOfMoscow localMoscowTimeFromDenotation | lateEveningInLondon := DateAndTime year: 2004 month: 11 day: 30 hour: 23 minute: 30 second: 0 offset: 0 hours. lateEveningInLocalTimeOfMoscow _ lateEveningInLondon utcOffset: 3 hours. localMoscowTimeFromDenotation _ '2004-12-01T02:30:00+03:00' asDateAndTime. self assert: lateEveningInLocalTimeOfMoscow = localMoscowTimeFromDenotation. ! ! !DateAndTimeTest methodsFor: 'Tests' stamp: 'BG 11/7/2004 12:18'! testTimeZoneEquivalence "DateAndTimeTest new testTimeZoneEquivalence" "When the clock on the wall in Detroit says 9:00am, the clock on the wall in London says 2:00pm. The Duration difference between the corresponding DateAndTime values should be zero." " Detroit is 5 hours behind UTC, this offset to UTC is therefore written with a minus sign. This example tests both the correct interpretation of the DateAndTime denotation and correct DateAndTime arithmetics. " | twoPmInLondon nineAmInDetroit durationDifference | twoPmInLondon _ '2004-11-02T14:00:00+00:00' asDateAndTime. nineAmInDetroit _ '2004-11-02T09:00:00-05:00' asDateAndTime. durationDifference _ twoPmInLondon - nineAmInDetroit. self assert: durationDifference asSeconds = 0. self assert: twoPmInLondon = nineAmInDetroit ! ! !DateAndTimeTest methodsFor: 'Tests' stamp: 'BG 11/7/2004 12:17'! testTimeZoneEquivalence2 "DateAndTimeTest new testTimeZoneEquivalence2" "This example demonstates the fact that 2004-05-24T22:40:00 UTC is 2004-05-25T01:40:00 in Moscow (Moscow is 3 hours ahead of UTC) " | thisMoment thisMomentInMoscow | thisMoment := DateAndTime year: 2004 month: 5 day: 24 hour: 22 minute: 40. thisMomentInMoscow := thisMoment utcOffset: 3 hours. self assert: (thisMoment - thisMomentInMoscow) asSeconds = 0. self assert: thisMoment = thisMomentInMoscow ! !