[squeak-dev] Testing membership in a Set of Date objects
Tim Johnson
digit at sonic.net
Sat Oct 20 19:17:38 UTC 2018
> On Oct 18, 2018, at 7:10 PM, Chris Muller <asqueaker at gmail.com> wrote:
>
> In the meantime, a fix is available by loading
> Chronology-Core-cmm.15.mcz from the Inbox. With that you can do
> everything. No limitations, just be sure when you use #asDate on a
> DateAndTime, since its a date that originated from a
> timezone-sensitive object, it retains that timezone, so if you want to
> use it in a system of canonical dates, you need to convert it by
> sending either #beCanonical or #stripTimezone (whichever you prefer),
> then it will compare equally with the one from "Date today" (which
> always produces a canonical date).
Thanks. I have had a chance to test this now. After loading Chronology-Core-cmm.15.mcz, a couple of my tests failed, as could be expected.
By adapting my method:
timespan
^ Timespan starting: (oldRecord timestamp) ending: (newRecord timestamp)
(considering the timestamps originate from DateAndTime class>>#now)
to:
timespan
^ (Timespan starting: (oldRecord timestamp) ending: (newRecord timestamp))
beCanonical
all my tests pass. Great!
My code relies on Timespan>>#dates. So, this is one test which failed with Chronology-Core-cmm.15.mcz until I made the change above:
self assert: (span2 dates includes: (Date year: 2018 month: 8 day: 16)).
(I was puzzled for a minute how my code would handle that #beCanonical and #stripTimezone modify objects in-place rather than returning modified copies... but as soon as I realized I could just make the above change, the clouds went away and life became beautiful.)
Thanks again,
Tim tcj
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20181020/84f88800/attachment.html>
More information about the Squeak-dev
mailing list
|