David T. Lewis uploaded a new version of Chronology-Tests to project The Trunk:
http://source.squeak.org/trunk/Chronology-Tests-dtl.13.mcz ==================== Summary ==================== Name: Chronology-Tests-dtl.13 Author: dtl Time: 5 January 2019, 6:25:04.438654 pm UUID: a1330c2e-f7b9-47f8-8438-7baf8be6a4db Ancestors: Chronology-Tests-dtl.12 Add tests to ensure that the Smalltalk epoch and Posix epoch are both treated as contants independent of time zone, and are separated by an agreed duration. Tests will fail in earlier versions of Chronology-Core, and pass now (after UTC updates). By definition, the Smalltalk epoch is January 01, 1901 midnight with localTimeZone = Greenwhich Meridian (local offset = 0 hours). By convention, and as enforced in the VM, the number of elapsed seconds from Smalltalk epoch to Posix epoch is 2177452800. Change method category from 'testing' to 'tests'. Revert TimeStampTest>>testFromSeconds to its original version written by Brent Pinkney. The bodged up version of the test from KernelTests-dtl.235 is no longer required, and will fail after latest Chronology-Core with UTC updates. =============== Diff against Chronology-Tests-dtl.12 =============== Item was changed: + ----- Method: DateAndTimeEpochTest>>testAsDate (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testAsDate (in category 'testing') ----- testAsDate self assert: aDateAndTime asDate = 'January 1, 1901' asDate. ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testAsDateAndTime (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testAsDateAndTime (in category 'testing') ----- testAsDateAndTime self assert: aDateAndTime asDateAndTime = aDateAndTime ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testAsDuration (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testAsDuration (in category 'testing') ----- testAsDuration self assert: aDateAndTime asDuration = 0 asDuration ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testAsLocal (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testAsLocal (in category 'testing') ----- testAsLocal self assert: aDateAndTime asLocal = aDateAndTime. self assert: aDateAndTime asLocal = (aDateAndTime utcOffset: aDateAndTime class localOffset) ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testAsMonth (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testAsMonth (in category 'testing') ----- testAsMonth self assert: aDateAndTime asMonth = (Month month: 'January' year: 1901). ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testAsNanoSeconds (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testAsNanoSeconds (in category 'testing') ----- testAsNanoSeconds self assert: aDateAndTime asNanoSeconds = 0 asDuration asNanoSeconds ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testAsSeconds (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testAsSeconds (in category 'testing') ----- testAsSeconds self assert: aDateAndTime asSeconds = 0 asDuration asSeconds ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testAsTime (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testAsTime (in category 'testing') ----- testAsTime self assert: aDateAndTime asTime = Time midnight. ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testAsTimeStamp (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testAsTimeStamp (in category 'testing') ----- testAsTimeStamp self assert: aDateAndTime asTimeStamp = TimeStamp new. ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testAsUTC (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testAsUTC (in category 'testing') ----- testAsUTC self assert: aDateAndTime asUTC = aDateAndTime ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testAsWeek (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testAsWeek (in category 'testing') ----- testAsWeek self assert: aDateAndTime asWeek = (Week starting: '12-31-1900' asDate). ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testAsYear (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testAsYear (in category 'testing') ----- testAsYear self assert: aDateAndTime asYear = (Year starting: '01-01-1901' asDate). ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testCurrent (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testCurrent (in category 'testing') ----- testCurrent self deny: aDateAndTime = (DateAndTime current). ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testDateTime (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testDateTime (in category 'testing') ----- testDateTime self assert: aDateAndTime = (DateAndTime date: '01-01-1901' asDate time: '00:00:00' asTime) ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testDay (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testDay (in category 'testing') ----- testDay self assert: aDateAndTime day = DateAndTime new day ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testDayMonthYearDo (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testDayMonthYearDo (in category 'testing') ----- testDayMonthYearDo |iterations| iterations := 0. self assert: (aDateAndTime dayMonthYearDo: [:eachDay :eachMonth :eachYear | iterations := iterations + 1]) = 1. self assert: (aDateAndTime dayMonthYearDo: [:eachDay :eachMonth :eachYear | eachYear]) = 1901. self assert: (aDateAndTime dayMonthYearDo: [:eachDay :eachMonth :eachYear | eachMonth]) = 1. self assert: (aDateAndTime dayMonthYearDo: [:eachDay :eachMonth :eachYear | eachDay]) = 1. ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testDayOfMonth (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testDayOfMonth (in category 'testing') ----- testDayOfMonth self assert: aDateAndTime dayOfMonth = 1. ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testDayOfWeek (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testDayOfWeek (in category 'testing') ----- testDayOfWeek self assert: aDateAndTime dayOfWeek = 3. self assert: aDateAndTime dayOfWeekAbbreviation = 'Tue'. self assert: aDateAndTime dayOfWeekName = 'Tuesday'. ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testDayOfYear (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testDayOfYear (in category 'testing') ----- testDayOfYear self assert: aDateAndTime dayOfYear = 1. ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testDaysInMonth (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testDaysInMonth (in category 'testing') ----- testDaysInMonth self assert: aDateAndTime daysInMonth = 31. ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testDaysInYear (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testDaysInYear (in category 'testing') ----- testDaysInYear self assert: aDateAndTime daysInYear = 365. ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testDaysLeftInYear (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testDaysLeftInYear (in category 'testing') ----- testDaysLeftInYear self assert: aDateAndTime daysLeftInYear = 364. ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testDuration (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testDuration (in category 'testing') ----- testDuration self assert: aDateAndTime duration = 0 asDuration. ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testEpoch (in category 'tests - epoch') ----- - ----- Method: DateAndTimeEpochTest>>testEpoch (in category 'testing') ----- testEpoch self assert: aDateAndTime = '1901-01-01T00:00:00+00:00' asDateAndTime ! Item was added: + ----- Method: DateAndTimeEpochTest>>testEpochHappenedOnlyOnce (in category 'tests - epoch') ----- + testEpochHappenedOnlyOnce + "The epoch is defined as January 01, 1901 midnight with localTimeZone = Greenwhich Meridian (local offset = 0 hours)" + + | epochInMichigan epochInKyoto | + self assert: aDateAndTime = '1901-01-01T00:00:00+00:00' asDateAndTime. + self assert: 0 equals: aDateAndTime asSeconds. + epochInMichigan := '1900-12-31T19:00:00-05:00' asDateAndTime. + self assert: 0 equals: epochInMichigan asSeconds. + self assert: aDateAndTime equals: epochInMichigan. + epochInKyoto := '1901-01-01T09:00:00+09:00' asDateAndTime. + self assert: 0 equals: epochInKyoto asSeconds. + self assert: aDateAndTime equals: epochInKyoto. + + ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testFirstDayOfMonth (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testFirstDayOfMonth (in category 'testing') ----- testFirstDayOfMonth self assert: aDateAndTime firstDayOfMonth = 1 ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testFromSeconds (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testFromSeconds (in category 'testing') ----- testFromSeconds self assert: aDateAndTime = (DateAndTime fromSeconds: 0). ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testFromString (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testFromString (in category 'testing') ----- testFromString self assert: aDateAndTime = (DateAndTime fromString: ' 1901-01-01T00:00:00+00:00'). self assert: aDateAndTime = (DateAndTime fromString: ' 1901-01-01T00:00:00'). self assert: aDateAndTime = (DateAndTime fromString: ' 1901-01-01T00:00'). self assert: aDateAndTime = (DateAndTime fromString: ' 1901-01-01T00:00:00+00:00'). ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testHash (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testHash (in category 'testing') ----- testHash self assert: aDateAndTime hash = DateAndTime new hash. self assert: aDateAndTime hash = 112557138 ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testHour (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testHour (in category 'testing') ----- testHour self assert: aDateAndTime hour = aDateAndTime hour24. self assert: aDateAndTime hour = 0. self assert: aDateAndTime hour = aDateAndTime hours ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testHour12 (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testHour12 (in category 'testing') ----- testHour12 self assert: aDateAndTime hour12 = DateAndTime new hour12. self assert: aDateAndTime hour12 = 12 ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testIsLeapYear (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testIsLeapYear (in category 'testing') ----- testIsLeapYear self deny: aDateAndTime isLeapYear ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testJulianDayNumber (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testJulianDayNumber (in category 'testing') ----- testJulianDayNumber self assert: aDateAndTime = (DateAndTime julianDayNumber: 2415386). self assert: aDateAndTime julianDayNumber = 2415386.! Item was changed: + ----- Method: DateAndTimeEpochTest>>testLessThan (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testLessThan (in category 'testing') ----- testLessThan self assert: aDateAndTime < (aDateAndTime + '1:00:00:00'). self assert: aDateAndTime + -1 < aDateAndTime. ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testMeridianAbbreviation (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testMeridianAbbreviation (in category 'testing') ----- testMeridianAbbreviation self assert: aDateAndTime meridianAbbreviation = 'AM'. ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testMiddleOf (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testMiddleOf (in category 'testing') ----- testMiddleOf self assert: (aDateAndTime middleOf: '2:00:00:00' asDuration) = (Timespan starting: '12-31-1900' asDate duration: 2 days). ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testMidnight (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testMidnight (in category 'testing') ----- testMidnight self assert: aDateAndTime midnight = aDateAndTime ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testMinus (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testMinus (in category 'testing') ----- testMinus self assert: aDateAndTime - aDateAndTime = '0:00:00:00' asDuration. self assert: aDateAndTime - '0:00:00:00' asDuration = aDateAndTime. self assert: aDateAndTime - aDuration = (DateAndTime year: 1900 month: 12 day: 30 hour: 21 minute: 56 second: 55 nanoSecond: 999999995 offset: 0 hours ). " I believe this Failure is a bug in the nanosecond part of (DateAndTime >> year:month:day:hour:minute:second:nanoSecond:offset:)" ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testMinute (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testMinute (in category 'testing') ----- testMinute self assert: aDateAndTime minute = 0 ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testMinutes (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testMinutes (in category 'testing') ----- testMinutes self assert: aDateAndTime minutes = 0 ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testMonth (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testMonth (in category 'testing') ----- testMonth self assert: aDateAndTime month = 1. self assert: aDateAndTime monthAbbreviation = 'Jan'. self assert: aDateAndTime monthName = 'January'. self assert: aDateAndTime monthIndex = 1.! Item was changed: + ----- Method: DateAndTimeEpochTest>>testNanoSecond (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testNanoSecond (in category 'testing') ----- testNanoSecond self assert: aDateAndTime nanoSecond = 0 ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testNew (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testNew (in category 'testing') ----- testNew self assert: aDateAndTime = (DateAndTime new). ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testNoon (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testNoon (in category 'testing') ----- testNoon self assert: aDateAndTime noon = '1901-01-01T12:00:00+00:00' asDateAndTime! Item was changed: + ----- Method: DateAndTimeEpochTest>>testNow (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testNow (in category 'testing') ----- testNow self deny: aDateAndTime = (DateAndTime now). ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testOffset (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testOffset (in category 'testing') ----- testOffset self assert: aDateAndTime offset = '0:00:00:00' asDuration. self assert: (aDateAndTime offset: '0:12:00:00') = '1901-01-01T00:00:00+12:00' asDateAndTime! Item was changed: + ----- Method: DateAndTimeEpochTest>>testPlus (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testPlus (in category 'testing') ----- testPlus self assert: aDateAndTime + '0:00:00:00' = aDateAndTime. self assert: aDateAndTime + 0 = aDateAndTime. self assert: aDateAndTime + aDuration = (DateAndTime year: 1901 month: 1 day: 2 hour: 2 minute: 3 second: 4 nanoSecond: 5 offset: 0 hours ) " I believe this is a bug in the nanosecond part of (DateAndTime >> year:month:day:hour:minute:second:nanoSecond:offset:)" ! Item was added: + ----- Method: DateAndTimeEpochTest>>testPosixEpoch (in category 'tests - epoch') ----- + testPosixEpoch + "The Smalltalk epoch happened, by agreed convention, 2177452800 seconds + prior to the Posix epoch, which is defined as 1970-01-01T00:00:00+00:00. + + Note for reference the corresponding implementation in the Unix VM: + + /* Squeak epoch is Jan 1, 1901. Unix epoch is Jan 1, 1970: 17 leap years + and 52 non-leap years later than Squeak. */ + return unixTime + ((52*365UL + 17*366UL) * 24*60*60UL);" + + | epochInMichigan epochInKyoto posixEpoch epochDelta | + epochDelta := 2177452800. + self assert: epochDelta equals: ((52*365 + (17*366)) * 24*60*60). "cross check against VM code" + posixEpoch := '1970-01-01T00:00:00+00:00' asDateAndTime. + self assert: epochDelta equals: posixEpoch asSeconds. + epochInMichigan := '1969-12-31T19:00:00-05:00' asDateAndTime. + self assert: epochDelta equals: epochInMichigan asSeconds. + self assert: posixEpoch equals: epochInMichigan. + epochInKyoto := '1970-01-01T09:00:00+09:00' asDateAndTime. + self assert: epochDelta equals: epochInKyoto asSeconds. + self assert: posixEpoch equals: epochInKyoto. + + ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testPrintOn (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testPrintOn (in category 'testing') ----- testPrintOn | ref ws | ref := '1901-01-01T00:00:00+00:00'. ws := '' writeStream. aDateAndTime printOn: ws. self assert: ws contents = ref. ref := 'a TimeZone(ETZ)'. ws := '' writeStream. aTimeZone printOn: ws. self assert: ws contents = ref! Item was changed: + ----- Method: DateAndTimeEpochTest>>testSecond (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testSecond (in category 'testing') ----- testSecond self assert: aDateAndTime second = 0 ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testSeconds (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testSeconds (in category 'testing') ----- testSeconds self assert: aDateAndTime seconds = 0 ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testTicks (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testTicks (in category 'testing') ----- testTicks self assert: aDateAndTime ticks = (DateAndTime julianDayNumber: 2415386) ticks. self assert: aDateAndTime ticks = #(2415386 0 0)! Item was changed: + ----- Method: DateAndTimeEpochTest>>testTicksOffset (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testTicksOffset (in category 'testing') ----- testTicksOffset self assert: aDateAndTime = (aDateAndTime ticks: #(2415386 0 0) offset: DateAndTime localOffset). ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testTo (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testTo (in category 'testing') ----- testTo self assert: (aDateAndTime to: aDateAndTime) = (DateAndTime new to: DateAndTime new) "MessageNotUnderstood: UndefinedObject>>starting:ending: where UndefinedObject is Timespan "! Item was changed: + ----- Method: DateAndTimeEpochTest>>testToBy (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testToBy (in category 'testing') ----- testToBy self assert: (aDateAndTime to: aDateAndTime + 10 days by: 5 days) = (DateAndTime new to: DateAndTime new + 10 days by: 5 days ) "MessageNotUnderstood: UndefinedObject>>starting:ending: where UndefinedObject is Timespan "! Item was changed: + ----- Method: DateAndTimeEpochTest>>testToByDo (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testToByDo (in category 'testing') ----- testToByDo "self assert: (aDateAndTime to: aDateAndTime + 10 days by: 5 days do: []) = " "MessageNotUnderstood: UndefinedObject>>starting:ending: where UndefinedObject is Timespan "! Item was changed: + ----- Method: DateAndTimeEpochTest>>testToday (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testToday (in category 'testing') ----- testToday self deny: aDateAndTime = (DateAndTime today). ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testTommorrow (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testTommorrow (in category 'testing') ----- testTommorrow self assert: (DateAndTime today + 24 hours) = (DateAndTime tomorrow). self deny: aDateAndTime = (DateAndTime tomorrow). "MessageNotUnderstood: Date class>>starting:"! Item was changed: + ----- Method: DateAndTimeEpochTest>>testUtcOffset (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testUtcOffset (in category 'testing') ----- testUtcOffset self assert: (aDateAndTime utcOffset: '0:12:00:00') = '1901-01-01T12:00:00+12:00' asDateAndTime! Item was changed: + ----- Method: DateAndTimeEpochTest>>testYear (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testYear (in category 'testing') ----- testYear self assert: aDateAndTime year = 1901. ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testYearDay (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testYearDay (in category 'testing') ----- testYearDay self assert: aDateAndTime = (DateAndTime year: 1901 day: 1). ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testYearDayHourMinuteSecond (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testYearDayHourMinuteSecond (in category 'testing') ----- testYearDayHourMinuteSecond self assert: aDateAndTime = (DateAndTime year: 1901 day: 1 hour: 0 minute: 0 second: 0). ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testYearMonthDay (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testYearMonthDay (in category 'testing') ----- testYearMonthDay self assert: aDateAndTime = (DateAndTime year: 1901 month: 1 day: 1). ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testYearMonthDayHourMinuteSecond (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testYearMonthDayHourMinuteSecond (in category 'testing') ----- testYearMonthDayHourMinuteSecond self assert: aDateAndTime = (DateAndTime year: 1901 month: 1 day: 1 hour: 0 minute: 0 second: 0). ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testYearMonthDayHourMinuteSecondNanosSecondOffset (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testYearMonthDayHourMinuteSecondNanosSecondOffset (in category 'testing') ----- testYearMonthDayHourMinuteSecondNanosSecondOffset self assert: aDateAndTime = (DateAndTime year: 1901 month: 1 day: 1 hour: 0 minute: 0 second: 0 nanoSecond: 0 offset:0 hours ). self assert: ((DateAndTime year: 1 month: 1 day: 1 hour: 0 minute: 0 second: 0 nanoSecond: 0 offset: 0 hours ) + (Duration days: 1 hours: 2 minutes: 3 seconds: 4 nanoSeconds: 5) ) = (DateAndTime year: 1 month: 1 day: 2 hour: 2 minute: 3 second: 4 nanoSecond: 5 offset: 0 hours ) " I believe this is a bug in the nanosecond part of (DateAndTime >> year:month:day:hour:minute:second:nanoSecond:offset:)"" I believe this is a bug in the nanosecond part of (DateAndTime >> year:month:day:hour:minute:second:nanoSecond:offset:)" ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testYesterday (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testYesterday (in category 'testing') ----- testYesterday self deny: aDateAndTime = (DateAndTime yesterday). ! Item was changed: + ----- Method: DateAndTimeEpochTest>>testtimeZone (in category 'tests') ----- - ----- Method: DateAndTimeEpochTest>>testtimeZone (in category 'testing') ----- testtimeZone self assert: aDateAndTime timeZoneName = 'Universal Time'. self assert: aDateAndTime timeZoneAbbreviation = 'UTC' ! Item was added: + ----- Method: DateAndTimeTest>>testAsSecondsIsTheSameInAnyTimezone (in category 'Tests') ----- + testAsSecondsIsTheSameInAnyTimezone + "Using the Posix epoch as a convenient reference, verify that this point + in time is represented with the same magnitude in any local time zone." + + | posixEpochInVariousLocations | + posixEpochInVariousLocations := { + '1970-01-01T00:00:00+00:00' asDateAndTime . + '1970-01-01T01:00:00+01:00' asDateAndTime . + '1970-01-01T02:00:00+02:00' asDateAndTime . + '1970-01-01T12:00:00+12:00' asDateAndTime . + '1969-12-31T23:00:00-01:00' asDateAndTime . + '1969-12-31T22:00:00-02:00' asDateAndTime . + '1969-12-31T12:00:00-12:00' asDateAndTime + }. + posixEpochInVariousLocations do: [ :e | + self assert: 2177452800 equals: e asSeconds ]. + ! Item was changed: ----- Method: TimeStampTest>>testFromSeconds (in category 'Tests') ----- testFromSeconds - "A time stamp from seconds is created in the local time zone, so offset may - be non-zero. The test timestamp has offset zero (implying UTC). Comparison - to the test timestamp should succeed if and only if both time stamps are - created relative to the same time zone (UTC)." + self + assert: (self timestampClass fromSeconds: 3124958100) = timestamp.! - | local utc | - local := self timestampClass fromSeconds: 3124958100. - local offset = Duration zero - ifTrue: [self assert: local = timestamp.] - ifFalse: [self deny: local = timestamp.]. - utc := local offset: Duration zero. - self assert: utc = timestamp.! |
Free forum by Nabble | Edit this page |