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

Chris Muller ma.chris.m at gmail.com
Mon Apr 29 02:45:13 UTC 2019


I see.  it would mess up the ability to set a different #startDay,
because some of them are depending on the assumption that Sunday is 1,
for example, DateAndTime>>#dayOfWeekName.

It could be useful if those places that depend on that assumption made
it explicit.  Like:

    dayOfWeekName
       ^ Week nameOfDay: (self dayOfWeekFrom: #Sunday)

The ones that aren't depending on that assumption could be left at #dayOfWeek.

Another option would be to go the other way.  Require the places that
want Other-Than-Sunday to specify that extra argument, and it maybe it
will usually be "Week startDay", but it's a heads-up to future reader.

Dave's recent updates took Chronology up a notch.  It's pretty clean
and pretty fast.  If we know we're going to be +1 selector in the
system, it could be #dayOfWeekFrom: instead of "localWeek" (just my
taste, no offense intended  :)  ).

 - Chris

On Sun, Apr 28, 2019 at 7:18 PM Chris Cunningham
<cunningham.cb at gmail.com> wrote:
>
> Hi Chris,
>
> I though of that.  The number of methods that derive off of dayOfWeek is significant in Week; I'm not sure where outside of Week it is used as well.
>
> Methods to change
> Week class
>   #indexOfDay:
>   #nameOfDay:
>   #starting:duration:
> Week instance
>
>
> On Sun, Apr 28, 2019 at 4:02 PM Chris Muller <asqueaker at gmail.com> wrote:
>>
>> What about keeping the existing selector #dayOfWeek, and making it
>> respect Week>>startDay?
>>
>>
>> On Sun, Apr 28, 2019 at 8:35 AM David T. Lewis <lewis at mail.msen.com> wrote:
>> >
>> > The addition of #dayOfLocalWeek is a good addition. But I want ask
>> > about the selector name and category. This isn't a criticism, more of
>> > a question because I do not understand how is it used in practice.
>> >
>> > We have #toggleStartMonday that changes start day to either #Monday or
>> > #Sunday. This is an original brp method, but I don't know the reason
>> > for it. And #dayOfWeek is listed in the 'ansi-protocol'. Is the start
>> > day of week actually specified in the ANSI standard?
>> >
>> > While I cannot think of any better selector name, I tend to think of
>> > "local" as refering to local time offset from UTC, so dayOfLocalWeek
>> > seems misleading in that sense. To me it seems more like dayOfLocalWeek
>> > is a dayOfWeek that is corrected for the toggled startDay. So maybe
>> > a name like correctedDayOfWeek or dayOfWeekCorrected might work? But
>> > these do not seem satisfactory either, because they do not suggest
>> > what is being corrected.
>> >
>> > Suggestions welcome, and if nobody can think of a better idea then I
>> > am +1 for moving this to trunk as it is.
>> >
>> > Dave
>> >
>> >
>> > On Mon, Apr 22, 2019 at 04:00:19PM +0000, 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.41.mcz
>> > >
>> > > ==================== Summary ====================
>> > >
>> > > Name: Chronology-Core-cbc.41
>> > > Author: cbc
>> > > Time: 22 April 2019, 8:58:13.835953 am
>> > > UUID: 3d8013b6-d58f-004e-8e6b-5a59ed5841e7
>> > > Ancestors: Chronology-Core-dtl.40
>> > >
>> > > We have the ability to change the starting day of the week (Week>>startDay:).
>> > > This change adds #dayOfLocalWeek to DateAndTime and Timespan to return the indexed day of the week based on the altered starting day.
>> > > Original #dayOfWeek is left as-is along with all other working code.
>> > >
>> > > =============== Diff against Chronology-Core-dtl.40 ===============
>> > >
>> > > Item was added:
>> > > + ----- Method: DateAndTime>>dayOfLocalWeek (in category 'ansi protocol') -----
>> > > + dayOfLocalWeek
>> > > +
>> > > +     "Sunday=1, ... , Saturday=7"
>> > > +
>> > > +     ^ (self julianDayNumber + 2 - Week weekdayStartIndex rem: 7) + 1
>> > > + !
>> > >
>> > > Item was added:
>> > > + ----- Method: Timespan>>dayOfLocalWeek (in category 'ansi protocol') -----
>> > > + dayOfLocalWeek
>> > > +     "Answer the day of the week represented by the receiver."
>> > > +
>> > > +     ^ start dayOfLocalWeek!
>> > >
>> > > Item was added:
>> > > + ----- Method: Week class>>weekdayStartIndex (in category 'squeak protocol') -----
>> > > + weekdayStartIndex
>> > > +     ^self indexOfDay: self startDay!
>> > >
>> > >
>> >
>>


More information about the Squeak-dev mailing list