logo       
Google Custom Search
    AddThis Social Bookmark Button

Re: WADateSelector - invalid date handling: msg#00115

Subject: Re: WADateSelector - invalid date handling
Dmitry Dorofeev wrote:
[snip]


But when I select 31 feb, i see message
You chose 1915-03-03.
For 30 feb i got
You chose 1915-03-02.

Hmm, with Seaside 2.5b7 and Squeak 3.7full image I get 3/3/2005 which definitely isn't the correct behavior either altough it makes a little more sense than what you're seeing. What version of Squeak are you running? My tutorial was written under 3.6...obviously something has changed with date handling so that invalid dates are no longer an error in the Date class. Frustrating. I can offer a patch to preserve the behavior of isValid. I could also patch the WADateSelector>>date method to validate the date. This would preserve the existing behavior in WADateSelector. Avi, any thoughts on this? "don't care" counts, I guess :-) Hell, I've just attached the patch, reasonbly close to preserving the previous behavior of #date and #isValid.

David

--
C. David Shaffer
http://www.cs.westminster.edu/~shaffer
http://www.shaffer-consulting.com

'From Squeak3.7 of ''4 September 2004'' [latest update: #5989] on 22 February 
2005 at 2:28:09 pm'!

!WADateSelector methodsFor: 'as yet unclassified' stamp: 'cds 2/22/2005 14:22'!
date
        (self privateIsValidDay: day monthNumber: month year: year)
                ifFalse: [self error: 'Invalid date'].
        ^ Date newDay: day monthNumber: month year: year! !

!WADateSelector methodsFor: 'as yet unclassified' stamp: 'cds 2/22/2005 14:27'!
privateIsValidDay: theDay monthNumber: theMonth year: theYear
        | maxDay |
        theMonth >= 0 & (theMonth < 12) ifFalse: [^false].
        maxDay := Month daysInMonth: theMonth forYear: theYear.
        ^theDay > 0 & (theDay <= maxDay)! !

_______________________________________________
Seaside mailing list
Seaside@xxxxxxxxxxxxxxxxxxxxxxxxxx
http://lists.squeakfoundation.org/listinfo/seaside

Try Searching:
servers, voip, java, networking, microsoft ...
<Prev in Thread] Current Thread [Next in Thread>