Stef, +1 What do you mean by "other languages?" If dialects of Smalltalk, Dolphin defines a hierarchy of *ToText converters, including Date and Time. When appropriate (as for date and time), they accept a format string that governs how they do left to right (e.g. Date to String) and right to left conversions. Anything that does not match the format raises an error. When faced with garbage data (2-digit dates are a good example of same IMHO), I end up making multiple converters with different formats, find (in sensible order) which one accepts the input, do any post-hoc tests I feel appropriate to validate that it read what I thought it read, and then set about trying to figure out, for example, just what in the DLL 07 means for a date. I am working on a set of Dolphin-like converters as part of my UI package. It's not much yet. If you thought y2k (laziness) was bad, wait for 2037 (design by committee) =:0 Bill -----Original Message----- From: pharo-project-bounces@lists.gforge.inria.fr [mailto:pharo-project-bounces@lists.gforge.inria.fr] On Behalf Of Stéphane Ducasse Sent: Saturday, January 16, 2010 4:06 PM To: Pharo-project@lists.gforge.inria.fr Subject: Re: [Pharo-project] Date fromString: '6-Jan-10' But if you deal with incomplete data why not building your own reader and control it. I think that a library class cannot be tuned to deal with all kind of crazy situation. I would prefer that Date is robust and consistent and that people implement their own custom situation. Does anybody know how it is done in other languages. Stef On Jan 16, 2010, at 9:36 PM, David Harris wrote:
I think a solution that can tuned or tweaked to it's application would be must useful. It's all very well to insist on users using four- digit years, but for processing historical data, for example, one doesn't have the luxury of insisting on the data format, but has to use what is there :-(
Perhaps a variable that determines the transition from 19xx to 20xx would be appropriate?
David PS- here in Canada we interpret 4/5/xxxx the opposite to the USA. I always use yyyy.mm.dd.hh.ss to the appropriate resolution :-)
On 2010-01-16, at 10:42 AM, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
Yes
Date fromString: '6-Jan-03' -> 6 January 2003
is also wrong. So david just tried to patch this wrong behavior.
Stef
On Jan 16, 2010, at 6:02 PM, csrabak@bol.com.br wrote:
I'm afraid the 'fix' is trying to repair something is not broken!
Date fromString: '6-Jan-10'. giving "6 January 1910" has not anything wrong. Within five year we'll have users/programmers complaining that:
Date fromString: '6-Jan-16'. gave "6 January 1916" and *obviously* it should have given "6 January 2015"!!
Rather document that years given with two figures get counted from 1900 (as it used to be in last century) and have people to use four digits for years in the 2000s.
Otherwise:
1) We need to get used to the concept of an epoch time for Pharo; or
2) the number to be tested has to be the current year!
My 0.019999. . .
-- Cesar Rabak
Em 16/01/2010 07:57, Stéphane Ducasse < stephane.ducasse@inria.fr
escreveu:
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: (5 April 1982; 5-APR-82) (April 5, 1982) (4/5/82) (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
_______________________________________________ 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
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project