[squeak-dev] The Inbox: Chronology-Core-cmm.15.mcz
Chris Muller
asqueaker at gmail.com
Thu Oct 18 20:14:31 UTC 2018
This one adds #beCanonical, for whenever you want canonical Dates from
a DateAndTime... (the usual case)
myDateAndTime asDate beCanonical
This will compare as we expect to any other canonical date.
We should have added this when we added #noTimezone since that was the
replacement for the prior #makeUTC approach...
On Thu, Oct 18, 2018 at 3:06 PM <commits at source.squeak.org> wrote:
>
> Chris Muller uploaded a new version of Chronology-Core to project The Inbox:
> http://source.squeak.org/inbox/Chronology-Core-cmm.15.mcz
>
> ==================== Summary ====================
>
> Name: Chronology-Core-cmm.15
> Author: cmm
> Time: 18 October 2018, 3:06:21.843002 pm
> UUID: 388f1031-54aa-49b4-a070-726ae1d5f489
> Ancestors: Chronology-Core-tcj.12
>
> - Add Timespan>>#beCanonical so that dates created via "myDateAndTime asDate" can be made canonical.
> - A fix and optimization of Timespan>>#=. Both elements being compared must have the same timezone (or same state of #noTimezone) in order to take advantage of the optimized #hasEqualTicks: comparison. Otherwise (if different timezones), a full comparison of their starts (via #=) is needed.
> - There was a mention of this optimization put into the class comment. This level of detail may be a bit tedious for users to read at that level, so Brents original comment was restored.
>
> =============== Diff against Chronology-Core-tcj.12 ===============
>
> Item was changed:
> Magnitude subclass: #Timespan
> instanceVariableNames: 'start duration'
> classVariableNames: ''
> poolDictionaries: ''
> category: 'Chronology-Core'!
>
> + !Timespan commentStamp: 'cmm 10/17/2018 22:00' prior: 0!
> + I represent a duration starting on a specific DateAndTime.!
> - !Timespan commentStamp: 'bf 2/18/2016 14:43' prior: 0!
> - I represent a duration starting on a specific DateAndTime.
> -
> - If my start has an offset identical to my #defaultOffset then comparisons ignore timezone offset.!
>
> Item was changed:
> ----- Method: Timespan>>= (in category 'ansi protocol') -----
> = comparand
> + ^ self class = comparand class
> + and: [(((self noTimezone and: [comparand noTimezone]) or: [self start offset = comparand start offset])
> + ifTrue: [ self start hasEqualTicks: comparand start ]
> + ifFalse: [ self start = comparand start ])
> + and: [ self duration = comparand duration ] ]
> - ^ self class = comparand class
> - and: [((self noTimezone or: [ comparand noTimezone ])
> - ifTrue: [ self start hasEqualTicks: comparand start ]
> - ifFalse: [ self start = comparand start ])
> - and: [ self duration = comparand duration ] ]
> .!
>
> Item was added:
> + ----- Method: Timespan>>beCanonical (in category 'squeak protocol') -----
> + beCanonical
> + "Make the receiver a canonical Date (or Month or Year) instead of a timespan of my duration starting at a specific local time. Canonical are the most common use of Dates in applications."
> + self stripTimezone!
>
> Item was added:
> + ----- Method: Timespan>>stripTimezone (in category 'squeak protocol') -----
> + stripTimezone
> + "Chronology preserves Timespans that are extracted from DateAndTime's, making Dates, Months and Years in Squeak able to represent a true Timespan of those durations starting at a specific local DateAndTime. In case a canonical version is needed, make the receiver independent of any Timezone by removing it."
> + start primOffset: self class defaultOffset!
>
>
More information about the Squeak-dev
mailing list
|