---------- Forwarded message ---------- From: <[hidden email]> Date: 2009/10/15 Subject: [squeak-dev] The Trunk: Kernel-ar.271.mcz To: [hidden email] Andreas Raab uploaded a new version of Kernel to project The Trunk: http://source.squeak.org/trunk/Kernel-ar.271.mcz ==================== Summary ==================== Name: Kernel-ar.271 Author: ar Time: 14 October 2009, 8:49:48 am UUID: a603d2fe-dccf-894f-95db-ef577480b03c Ancestors: Kernel-nice.270, Kernel-ul.270 Merging Kernel-ul.270: - faster DateAndTime and Date creation with #year:month:day: and friends - minor formatting fixes =============== Diff against Kernel-nice.270 =============== Item was changed: ----- Method: DateAndTime>>midnight (in category 'squeak protocol') ----- midnight "Answer a DateAndTime starting at midnight local time" + ^self class basicNew + setJdn: jdn + seconds: 0 + nano: 0 + offset: self class localOffset - ^ self - dayMonthYearDo: [ :d :m :y | self class year: y month: m day: d ] ! Item was changed: ----- Method: DateAndTime class>>year:month:day:hour:minute: (in category 'squeak protocol') ----- year: year month: month day: day hour: hour minute: minute + "Return a DateAndTime" + ^self - "Return a DateAndTime" ^ self year: year month: month day: day hour: hour minute: minute second: 0 ! Item was changed: ----- Method: DateAndTime class>>year:month:day:hour:minute:second:nanoSecond:offset: (in category 'squeak protocol') ----- year: year month: month day: day hour: hour minute: minute second: second nanoSecond: nanoCount offset: offset "Return a DateAndTime" + | monthIndex daysInMonth p q r s julianDayNumber | - | monthIndex daysInMonth p q r s julianDayNumber since | monthIndex := month isInteger ifTrue: [month] ifFalse: [Month indexOfMonth: month]. daysInMonth := Month daysInMonth: monthIndex forYear: year. day < 1 ifTrue: [self error: 'day may not be zero or negative']. day > daysInMonth ifTrue: [self error: 'day is after month ends']. p := (monthIndex - 14) quo: 12. q := year + 4800 + p. r := monthIndex - 2 - (12 * p). s := (year + 4900 + p) quo: 100. julianDayNumber := ( (1461 * q) quo: 4 ) + ( (367 * r) quo: 12 ) - ( (3 * s) quo: 4 ) + ( day - 32075 ). + ^self basicNew + setJdn: julianDayNumber + seconds: hour * 60 + minute * 60 + second + nano: nanoCount + offset: offset; - since := Duration days: julianDayNumber hours: hour - minutes: minute seconds: second nanoSeconds: nanoCount. - - ^ self basicNew - ticks: since ticks offset: offset; yourself! Item was changed: ----- Method: DateAndTime class>>year:month:day: (in category 'squeak protocol') ----- year: year month: month day: day + "Return a DateAndTime, midnight local time" + + ^self - "Return a DateAndTime, midnight local time" ^ self year: year month: month day: day hour: 0 minute: 0 ! -- Cédrick _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
thanks cedric
did you get a chance to check because I thought we did something like that too. Stef On Oct 15, 2009, at 11:48 AM, Cédrick Béler wrote: > > > ---------- Forwarded message ---------- > From: <[hidden email]> > Date: 2009/10/15 > Subject: [squeak-dev] The Trunk: Kernel-ar.271.mcz > To: [hidden email] > > > Andreas Raab uploaded a new version of Kernel to project The Trunk: > http://source.squeak.org/trunk/Kernel-ar.271.mcz > > ==================== Summary ==================== > > Name: Kernel-ar.271 > Author: ar > Time: 14 October 2009, 8:49:48 am > UUID: a603d2fe-dccf-894f-95db-ef577480b03c > Ancestors: Kernel-nice.270, Kernel-ul.270 > > Merging Kernel-ul.270: > > - faster DateAndTime and Date creation with #year:month:day: and > friends > - minor formatting fixes > > =============== Diff against Kernel-nice.270 =============== > > Item was changed: > ----- Method: DateAndTime>>midnight (in category 'squeak protocol') > ----- > midnight > "Answer a DateAndTime starting at midnight local time" > > + ^self class basicNew > + setJdn: jdn > + seconds: 0 > + nano: 0 > + offset: self class localOffset > - ^ self > - dayMonthYearDo: [ :d :m :y | self class year: y > month: m day: d ] > ! > > Item was changed: > ----- Method: DateAndTime class>>year:month:day:hour:minute: (in > category 'squeak protocol') ----- > year: year month: month day: day hour: hour minute: minute > + "Return a DateAndTime" > > + ^self > - "Return a DateAndTime" ^ self > year: year > month: month > day: day > hour: hour > minute: minute > second: 0 > ! > > Item was changed: > ----- Method: DateAndTime > class>>year:month:day:hour:minute:second:nanoSecond:offset: (in > category 'squeak protocol') ----- > year: year month: month day: day hour: hour minute: minute second: > second nanoSecond: nanoCount offset: offset > "Return a DateAndTime" > > + | monthIndex daysInMonth p q r s julianDayNumber | > - | monthIndex daysInMonth p q r s julianDayNumber since | > > monthIndex := month isInteger ifTrue: [month] ifFalse: [Month > indexOfMonth: month]. > daysInMonth := Month > daysInMonth: monthIndex > forYear: year. > day < 1 ifTrue: [self error: 'day may not be zero or > negative']. > day > daysInMonth ifTrue: [self error: 'day is after month > ends']. > > p := (monthIndex - 14) quo: 12. > q := year + 4800 + p. > r := monthIndex - 2 - (12 * p). > s := (year + 4900 + p) quo: 100. > > julianDayNumber := > ( (1461 * q) quo: 4 ) + > ( (367 * r) quo: 12 ) - > ( (3 * s) quo: 4 ) + > ( day - 32075 ). > > + ^self basicNew > + setJdn: julianDayNumber > + seconds: hour * 60 + minute * 60 + second > + nano: nanoCount > + offset: offset; > - since := Duration days: julianDayNumber hours: hour > - minutes: minute seconds: second > nanoSeconds: nanoCount. > - > - ^ self basicNew > - ticks: since ticks offset: offset; > yourself! > > Item was changed: > ----- Method: DateAndTime class>>year:month:day: (in category > 'squeak protocol') ----- > year: year month: month day: day > + "Return a DateAndTime, midnight local time" > + > + ^self > - "Return a DateAndTime, midnight local time" ^ self > year: year > month: month > day: day > hour: 0 > minute: 0 > ! > > > > > > -- > Cédrick > _______________________________________________ > Pharo-project mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
TestInstance:
DateAndTime year: 2009 month: 11 day: 15 creation methods: 8-10 times faster midnight - ~25 times faster Published to Inbox as SLICE-DateAndTimeCreation. Cheers, Henry Workspace used to test: |date| date := DateAndTime year: 2009 month: 11 day: 15. [500000 timesRepeat: [date midnight]] timeToRun. 370 9660 [500000 timesRepeat: [DateAndTime year: 2009 month: 11 day: 15]] timeToRun. 914 8697 Stéphane Ducasse skrev: > thanks cedric > did you get a chance to check because I thought we did something like > that too. > > Stef > > On Oct 15, 2009, at 11:48 AM, Cédrick Béler wrote: > > >> ---------- Forwarded message ---------- >> From: <[hidden email]> >> Date: 2009/10/15 >> Subject: [squeak-dev] The Trunk: Kernel-ar.271.mcz >> To: [hidden email] >> >> >> Andreas Raab uploaded a new version of Kernel to project The Trunk: >> http://source.squeak.org/trunk/Kernel-ar.271.mcz >> >> ==================== Summary ==================== >> >> Name: Kernel-ar.271 >> Author: ar >> Time: 14 October 2009, 8:49:48 am >> UUID: a603d2fe-dccf-894f-95db-ef577480b03c >> Ancestors: Kernel-nice.270, Kernel-ul.270 >> >> Merging Kernel-ul.270: >> >> - faster DateAndTime and Date creation with #year:month:day: and >> friends >> - minor formatting fixes >> >> =============== Diff against Kernel-nice.270 =============== >> >> Item was changed: >> ----- Method: DateAndTime>>midnight (in category 'squeak protocol') >> ----- >> midnight >> "Answer a DateAndTime starting at midnight local time" >> >> + ^self class basicNew >> + setJdn: jdn >> + seconds: 0 >> + nano: 0 >> + offset: self class localOffset >> - ^ self >> - dayMonthYearDo: [ :d :m :y | self class year: y >> month: m day: d ] >> ! >> >> Item was changed: >> ----- Method: DateAndTime class>>year:month:day:hour:minute: (in >> category 'squeak protocol') ----- >> year: year month: month day: day hour: hour minute: minute >> + "Return a DateAndTime" >> >> + ^self >> - "Return a DateAndTime" ^ self >> year: year >> month: month >> day: day >> hour: hour >> minute: minute >> second: 0 >> ! >> >> Item was changed: >> ----- Method: DateAndTime >> class>>year:month:day:hour:minute:second:nanoSecond:offset: (in >> category 'squeak protocol') ----- >> year: year month: month day: day hour: hour minute: minute second: >> second nanoSecond: nanoCount offset: offset >> "Return a DateAndTime" >> >> + | monthIndex daysInMonth p q r s julianDayNumber | >> - | monthIndex daysInMonth p q r s julianDayNumber since | >> >> monthIndex := month isInteger ifTrue: [month] ifFalse: [Month >> indexOfMonth: month]. >> daysInMonth := Month >> daysInMonth: monthIndex >> forYear: year. >> day < 1 ifTrue: [self error: 'day may not be zero or >> negative']. >> day > daysInMonth ifTrue: [self error: 'day is after month >> ends']. >> >> p := (monthIndex - 14) quo: 12. >> q := year + 4800 + p. >> r := monthIndex - 2 - (12 * p). >> s := (year + 4900 + p) quo: 100. >> >> julianDayNumber := >> ( (1461 * q) quo: 4 ) + >> ( (367 * r) quo: 12 ) - >> ( (3 * s) quo: 4 ) + >> ( day - 32075 ). >> >> + ^self basicNew >> + setJdn: julianDayNumber >> + seconds: hour * 60 + minute * 60 + second >> + nano: nanoCount >> + offset: offset; >> - since := Duration days: julianDayNumber hours: hour >> - minutes: minute seconds: second >> nanoSeconds: nanoCount. >> - >> - ^ self basicNew >> - ticks: since ticks offset: offset; >> yourself! >> >> Item was changed: >> ----- Method: DateAndTime class>>year:month:day: (in category >> 'squeak protocol') ----- >> year: year month: month day: day >> + "Return a DateAndTime, midnight local time" >> + >> + ^self >> - "Return a DateAndTime, midnight local time" ^ self >> year: year >> month: month >> day: day >> hour: 0 >> minute: 0 >> ! >> >> >> >> >> >> -- >> Cédrick >> _______________________________________________ >> Pharo-project mailing list >> [hidden email] >> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >> > > > _______________________________________________ > Pharo-project mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > > > _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
Free forum by Nabble | Edit this page |