[squeak-dev] The Inbox: Chronology-Core-cbc.45.mcz

David T. Lewis lewis at mail.msen.com
Wed May 15 00:32:45 UTC 2019


+1

The original code answered a new instance if and only if the offset
of aDateAndTime was different from DateAndTime class>>localOffset,
whatever that might happen to be. The method name #asLocal implies
that it should (consistently) answer a new instance. That sounds
more correct to me, so as long as the tests still pass and nothing
else is broken, please move it to trunk.

Dave

On Tue, May 14, 2019 at 03:38:28PM -0700, Chris Cunningham wrote:
> Apparently I use this, but not where I run into it every day.
> 
> And there are test to make sure #asLocal works - but they involve having
> aDateAndTime set, then comparing aDateAndTime asLocal = aDateAndTime, which
> obviously works.  Since the previous code actually changed aDateAndTime,
> the two are identical (as opposed to just equivalent).
> 
> If no one objects, I'll move this into trunk in a couple of days.
> 
> -cbc
> 
> On Tue, May 14, 2019 at 3:33 PM <commits at source.squeak.org> wrote:
> 
> > Chris Cunningham uploaded a new version of Chronology-Core to project The
> > Inbox:
> > http://source.squeak.org/inbox/Chronology-Core-cbc.45.mcz
> >
> > ==================== Summary ====================
> >
> > Name: Chronology-Core-cbc.45
> > Author: cbc
> > Time: 14 May 2019, 3:33:13.333275 pm
> > UUID: 4117cd16-a46a-4647-9630-49ee93d3f725
> > Ancestors: Chronology-Core-nice.44
> >
> > With the UTC / DateAndTime changs, DateAndTime>>utcOffset: changed to
> > update the existing instance in place instead of creating a new instance.
> > The change fixes #asLocal to create a new instance, bypassing #utcOffset:.
> > Follows the same logic as used in #asUTC
> >
> > =============== Diff against Chronology-Core-nice.44 ===============
> >
> > Item was changed:
> >   ----- Method: DateAndTime>>asLocal (in category 'ansi protocol') -----
> >   asLocal
> > +       "Anwer a copy of oursielves (if necessary) in the local timezone.
> > #utcOffset: now modifies my instance, so the creation of the new instance
> > should happen here."
> > -
> >
> >         ^ (self offset = self class localOffset)
> > -
> >                 ifTrue: [self]
> > +               ifFalse: [self copy localOffsetSeconds: self class
> > localOffset asSeconds]!
> > -               ifFalse: [self utcOffset: self class localOffset]!
> >
> >
> >

> 



More information about the Squeak-dev mailing list