On Jan 16, 2010, at 11:07 AM, Matthias Berth wrote:
don't know if this addresses your confusion:
before: '5-APR-10' got parsed as April 5, 1910 after: '5-APR-10' gets parsed as April 5, 2010
so it kind of fixes the passing of time :-)
This kind of cleverness should not be there, IMHO.
+1 Confirmed.
a) you want to parse special date formats: you should use some explicit format descriptions (that %M%D%Y stuff) and make it explicit.
b) you want to make some best effort to parse whatever string as a date: that is a heuristic and it should be in another method, not something as basic as #readFrom:. Maybe call the method guessFrom: aStream ;-)
I agree because in 10 years we will have to <30 and it is plain wrong anyway :) Stef
Cheers
Matthias
On Sat, Jan 16, 2010 at 10:57 AM, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
hi guys
can one of you give a look at the this fix because I'm confused. Kernel-DavidHotham.538
year < 20 ifTrue: [year := 2000 + year] was year < 10 ifTrue: [year := 2000 + year]
both solutions look strange to me.
http://code.google.com/p/pharo/issues/detail?id=1749
readFrom: aStream "Read a Date from the stream in any of the forms: <day> <monthName> <year> (5 April 1982; 5-APR-82) <monthName> <day> <year> (April 5, 1982) <monthNumber> <day> <year> (4/5/82) <day><monthName><year> (5APR82)" | day month year | aStream peek isDigit ifTrue: [day := Integer readFrom: aStream]. [aStream peek isAlphaNumeric] whileFalse: [aStream skip: 1]. aStream peek isLetter ifTrue: ["number/name... or name..." month := (String new: 10) writeStream. [aStream peek isLetter] whileTrue: [month nextPut: aStream next]. month := month contents. day isNil ifTrue: ["name/number..." [aStream peek isAlphaNumeric] whileFalse: [aStream skip: 1]. day := Integer readFrom: aStream]] ifFalse: ["number/number..." month := Month nameOfMonth: day. day := Integer readFrom: aStream]. [aStream peek isAlphaNumeric] whileFalse: [aStream skip: 1]. year := Integer readFrom: aStream.
year < 20 ifTrue: [year := 2000 + year]
ifFalse: [ year < 1900 ifTrue: [ year := 1900 + year]].
^ self year: year month: month day: day _______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project