[Glass] Comment of #newDay:monthNumber:year: is wrong (and I do not like the behavior either!)

Dale Henrichs via Glass glass at lists.gemtalksystems.com
Wed Oct 21 07:56:40 PDT 2015


Looks like this bug is fixed in 3.3 ... it should show up in the release 
notes for 3.3...

Dale

On 10/21/15 7:51 AM, Mariano Martinez Peck wrote:
>
>
> On Tue, Aug 11, 2015 at 8:08 PM, Dale Henrichs 
> <dale.henrichs at gemtalksystems.com 
> <mailto:dale.henrichs at gemtalksystems.com>> wrote:
>
>     Mariano,
>
>     FYI, your patch will be included in 3.2.8 and 3.3 ...
>
>
> Dale, I am testing in 3.2.9 and a quick test shows like if this was 
> finally fixed. Is there a chance you confirm me this issue was finally 
> fully integrated in 3.2.8?  I am checking 
> https://gemtalksystems.com/data/bugsByVersion/bugnotes_GS64_327.html
> but I do not see it there. The internal number was 45525.
>
> Thanks in advance,
>
>
>     Dale
>
>
>     On 08/10/2015 03:46 PM, Mariano Martinez Peck wrote:
>>     OK Dale,
>>     So here is the (hopefully) final fix. Hope it helps others. I
>>     only tested agains 3.1.0.6.
>>
>>     Best,
>>
>>
>>
>>     Date  class compileMethod: ' numberOfDaysIn: month year: aYear
>>
>>     ((month == 1) or: [(month == 3) or: [(month == 5) or: [(month ==
>>     7) or:
>>        [(month == 8) or: [(month == 10) or: [(month == 12)]]]]]])
>>        ifTrue: [^ 31].
>>     ((month == 4) or: [(month == 6) or: [(month == 9) or: [(month ==
>>     11)]]])
>>        ifTrue: [^ 30].
>>     (((aYear \\ 100) == 0)
>>        ifTrue: [ ((aYear \\ 400) == 0)]
>>        ifFalse: [ ((aYear \\ 4) == 0) ])
>>       ifTrue: [^ 29].
>>     ^ 28
>>     '
>>     dictionaries: GsSession currentSession symbolList
>>     category: 'Accessing'
>>     environmentId: 0.
>>
>>
>>
>>     Date  class compileMethod: '_newDay: day monthNumber: month year:
>>     year
>>
>>     <primitive: 316>
>>
>>     day _validateClass: SmallInteger .
>>     month _validateClass: SmallInteger .
>>     year _validateClass: SmallInteger .
>>
>>     ^ self _primitiveFailed: #newDay:monthNumber:year:
>>            args: { day . month . year }
>>     '
>>     dictionaries: GsSession currentSession symbolList
>>     category: 'Instance Creation'
>>     environmentId: 0.
>>
>>
>>     Date  class compileMethod: 'newDay: day monthNumber: month year: year
>>
>>     (month between: 1 and: 12) ifFalse: [ self error: ''Incorrect
>>     specified month: '', month asString].
>>     (day between: 1 and: (self numberOfDaysIn: month year: year))
>>     ifFalse: [ self error: ''Incorrect specified day: '', day asString].
>>
>>     ^ self _newDay: day monthNumber: month year: year
>>     '
>>     dictionaries: GsSession currentSession symbolList
>>     category: 'Instance Creation'
>>     environmentId: 0.
>>
>>
>>
>>     Date compileMethod: 'addMonths: anInteger
>>
>>     "Returns a Date that describes a date anInteger months later than
>>     that of the
>>      receiver.
>>
>>      This method attempts to keep the day of the month the same.  If the
>>      new month has fewer days than the receiver''s original month,
>>     then it
>>      truncates to the last day of the new month."
>>
>>     | yr month day newYear newMonth newDay newDate generatedDay |
>>
>>     yr := self year.
>>     month := self month.
>>     day := self day.
>>
>>     newMonth := month + anInteger.
>>     newYear := yr + ((newMonth - 1) // 12).
>>     newMonth := (newMonth - 1) \\ 12 + 1.
>>     newDate := self class _newDay: day monthNumber: newMonth year:
>>     newYear.
>>     generatedDay := newDate day.
>>     (generatedDay ~= day)
>>       ifTrue: [
>>         newDay := newDate _daysInMonth: newMonth.
>>         newDate := self class _newDay: newDay monthNumber: newMonth
>>     year: newYear
>>         ].
>>     ^ newDate.
>>
>>     '
>>     dictionaries: GsSession currentSession symbolList
>>     category: 'Arithmetic'
>>     environmentId: 0.
>>
>>
>>     Date compileMethod: 'addYears: anInteger
>>
>>     "Returns a Date that describes a date anInteger years later than
>>     that of the
>>      receiver."
>>
>>     | yr month day newYear newDay newDate generatedDay |
>>
>>     yr := self year.
>>     month := self month.
>>     day := self day.
>>
>>     newYear := yr + anInteger.
>>     newDate := self class _newDay: day monthNumber: month year: newYear.
>>     generatedDay := newDate day.
>>     (generatedDay ~= day)
>>       ifTrue: [
>>         newDay := newDate _daysInMonth: month.
>>         newDate := self class _newDay: newDay monthNumber: month
>>     year: newYear
>>         ].
>>     ^ newDate.
>>
>>     '
>>     dictionaries: GsSession currentSession symbolList
>>     category: 'Arithmetic'
>>     environmentId: 0.
>>
>>
>>     Date class compileMethod: 'newDay: day year: year
>>
>>     "Creates and returns an instance of the receiver from the
>>     specified values.
>>      Generates an error if any of the values are out of range."
>>
>>     ^ self _newDay: day monthNumber: 1 year: year.
>>
>>     '
>>     dictionaries: GsSession currentSession symbolList
>>     category: 'Instance Creation'
>>     environmentId: 0.
>>
>>
>>     System commit.
>>
>>     On Mon, Aug 10, 2015 at 7:13 PM, Dale Henrichs
>>     <dale.henrichs at gemtalksystems.com
>>     <mailto:dale.henrichs at gemtalksystems.com>> wrote:
>>
>>
>>
>>         On 08/10/2015 03:00 PM, Mariano Martinez Peck wrote:
>>>
>>>
>>>
>>>         But as said, it's not easy. We must go one by one the
>>>         senders of #newDay:monthNumber:year:  and see if there are
>>>         more problematics. So far:
>>>
>>>         Date class >> newDay: day year: year
>>>         Date >> addMonths:
>>>         Date >> addYears:
>>>
>>>         So for those 3 methods above, we should actually send the
>>>         new message #_newDay:monthNumber:year: (wrong behavior) and
>>>         let the rest use the fixed #newDay:monthNumber:year:
>>>
>>>         Thoughts?
>>>
>>         This was the direction that I was thinking. These changes
>>         look like they should cover all of the cases ...
>>
>>         Dale
>>
>>
>>
>>
>>     -- 
>>     Mariano
>>     http://marianopeck.wordpress.com
>
>
>
>
> -- 
> Mariano
> http://marianopeck.wordpress.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gemtalksystems.com/mailman/private/glass/attachments/20151021/48ef264e/attachment.html>


More information about the Glass mailing list