John Siracusa schreef: > On 7/16/03 2:16 PM, Eugene van der Pijll wrote: > > Most of the formatting modules don't know what to do with infinite dates. > > That's a bug/feature in the formatting modules, IMO, not a reason to pretend > that infinite dates don't exist.
Infinite dates do not exist. (And neither do undefined ones.) > > Similarly, most of the programs using DT won't use infinite dates. It is a > > pain to check for infinity everywhere. > > ....and yet you must do so anyway if you write subroutines that accept > DateTime objects, but that want to reject infinite dates. A Format object does not have to accept every deranged monstrosity that is subclassed from DateTime. For example, my Format modules are documented to accept DateTime objects. > >> I don't think infinity needs to be locale aware. "Inf" will not be locale > >> aware in Perl 6, AFAIK, for example. > > > > Perl 6 is for programmers. I thought you needed the DT::F::Simple module > > for user input. > > Programmers are users too :) In this situation, you can think of it as a > shorter constructor for brief/simple scripts (since the arguments to > DateTime->new() are very verbose). This was another one of the motivators > for DT::F::Simple, if you look back at the thread. I know, and it would be mine. But this means that DT::F::Simple would try to be two things: 1) it wants to parse all common datetime strings that a (naive?) user would pass to the program. To do this, it has to be as lenient as possible, whilst being aware of locale issues, and if possible, it should be able to interpret the most likely meaning of defective input like 01/02/03. It should be able to parse such simple phrases as 'now', but not unintuitive mathematical concepts. 2) it wants to provide a shorter constructor. To do this, it should be exactly defined how formats are interpreted. Special phrases are provided to construct some special DT constructs (aka deranged monstrosities), like '+inf' and '-inf'. It is not necessary to duplicate other methods, so e.g. 'now' is not needed; DateTime::now() is perfectly adequate. Combining these two aims is perhaps possible. Calling the result Simple is a chutzpah. Making it the default for DT parsing... > > If English users try to submit the string "infinite" in a web form (I doubt > > it, but hypothetically...), Dutch users would certainly type "oneindig". > > I'm not really "against" localization in this case. I think "natural > language" is outside the scope of DT::F::Simple. But "natural date formats" are inside the scope of DT::F::S, right? And "infinite" is a date, right? > Simple things like "now" > and "today" should get parsed, but not "right now" or "the day after > yesterday" If "today" is parsed, people expect "tomorrow" to be parsed as well". And if "tomorrow" is parsed, "overmorrow" should also be parsed. (At least, in those languages where the word "overmorrow" is not deprecated.) (Rick! Does DT::F::Natural parse "overmorrow" already? "ere-yesterday"?) Eugene