David T. Lewis uploaded a new version of Chronology-Tests to project The Inbox:
http://source.squeak.org/inbox/Chronology-Tests-dtl.8.mcz ==================== Summary ==================== Name: Chronology-Tests-dtl.8 Author: dtl Time: 4 December 2016, 12:39:59.762389 pm UUID: 778d4c7e-448d-41f9-8aa2-18bfc6d6c3ce Ancestors: Chronology-Tests-dtl.7 DateAndTime asSeconds should refer to seconds since the Smalltalk epoch. =============== Diff against Chronology-Tests-dtl.7 =============== Item was added: + ----- Method: DateAndTimeTest>>testAsSeconds (in category 'Tests') ----- + testAsSeconds + "Verify seconds elapsed from the Smalltalk epoch until a specified DateAndTime 2004-02-29T13:33:00+02:00" + + | aDateAndTime first28DaysOfFebruary2004 firstElevenHoursOfFebruary29 monthOfJanuary2004 posixEpochUntilJanuary2004 smalltalkEpochUntilPosixEpoch thirtyThreeMinutesOfTheEleventhHour totalElapsedSeconds | + + aDateAndTime := (DateAndTime year: 2004 month: 2 day: 29 hour: 13 minute: 33 second: 0 offset: 2 hours). + smalltalkEpochUntilPosixEpoch := 24 * 60 * 60 * ((52*365) + (17*366)). + posixEpochUntilJanuary2004 := 24 * 60 * 60 * ((26*365) + (8*366)). + monthOfJanuary2004 := 31 * 24 * 60 * 60. + first28DaysOfFebruary2004 := 28 * 24 * 60 * 60. + firstElevenHoursOfFebruary29 := 11 * 60 * 60. + thirtyThreeMinutesOfTheEleventhHour := 33 * 60. + totalElapsedSeconds := smalltalkEpochUntilPosixEpoch + posixEpochUntilJanuary2004 + monthOfJanuary2004 + first28DaysOfFebruary2004 + firstElevenHoursOfFebruary29 + thirtyThreeMinutesOfTheEleventhHour. + self assert: totalElapsedSeconds equals: aDateAndTime asSeconds. "3255507180" + ! |
Submitted to the inbox for discussion.
I claim that backward compatibility of DateAndTime class>>asSeconds is not important in this case, because anyone who requires consistent second stamps will have written workarounds already. Dave On Sun, Dec 04, 2016 at 05:40:06PM +0000, [hidden email] wrote: > David T. Lewis uploaded a new version of Chronology-Tests to project The Inbox: > http://source.squeak.org/inbox/Chronology-Tests-dtl.8.mcz > > ==================== Summary ==================== > > Name: Chronology-Tests-dtl.8 > Author: dtl > Time: 4 December 2016, 12:39:59.762389 pm > UUID: 778d4c7e-448d-41f9-8aa2-18bfc6d6c3ce > Ancestors: Chronology-Tests-dtl.7 > > DateAndTime asSeconds should refer to seconds since the Smalltalk epoch. > > =============== Diff against Chronology-Tests-dtl.7 =============== > > Item was added: > + ----- Method: DateAndTimeTest>>testAsSeconds (in category 'Tests') ----- > + testAsSeconds > + "Verify seconds elapsed from the Smalltalk epoch until a specified DateAndTime 2004-02-29T13:33:00+02:00" > + > + | aDateAndTime first28DaysOfFebruary2004 firstElevenHoursOfFebruary29 monthOfJanuary2004 posixEpochUntilJanuary2004 smalltalkEpochUntilPosixEpoch thirtyThreeMinutesOfTheEleventhHour totalElapsedSeconds | > + > + aDateAndTime := (DateAndTime year: 2004 month: 2 day: 29 hour: 13 minute: 33 second: 0 offset: 2 hours). > + smalltalkEpochUntilPosixEpoch := 24 * 60 * 60 * ((52*365) + (17*366)). > + posixEpochUntilJanuary2004 := 24 * 60 * 60 * ((26*365) + (8*366)). > + monthOfJanuary2004 := 31 * 24 * 60 * 60. > + first28DaysOfFebruary2004 := 28 * 24 * 60 * 60. > + firstElevenHoursOfFebruary29 := 11 * 60 * 60. > + thirtyThreeMinutesOfTheEleventhHour := 33 * 60. > + totalElapsedSeconds := smalltalkEpochUntilPosixEpoch + posixEpochUntilJanuary2004 + monthOfJanuary2004 + first28DaysOfFebruary2004 + firstElevenHoursOfFebruary29 + thirtyThreeMinutesOfTheEleventhHour. > + self assert: totalElapsedSeconds equals: aDateAndTime asSeconds. "3255507180" > + ! > > |
Free forum by Nabble | Edit this page |