Re: PEP 321: Date/Time Parsing and Formatting

From: John Roth (newsgroups_at_jhrothjr.com)
Date: 11/18/03


Date: Tue, 18 Nov 2003 17:36:36 -0500


"Paul Moore" <pf_moore@yahoo.co.uk> wrote in message
news:ekw5gxzo.fsf@yahoo.co.uk...
> "John Roth" <newsgroups@jhrothjr.com> writes:
>
> > The trouble with "guess the format" is that it's not possible
> > to do it correctly in the general case from one sample.
> > Given enough samples of one consistent format, it's
> > certainly possible. However, that's a two pass process.
>
> I think you can do it with a hint or two. The key one is whether in
> ambiguous cases, you choose DD/MM or MM/DD. You need a second hint
> with 2-digit years, as 01-02-03 is *very* ambiguous (given that
> putting the year in the middle is insane, you only need a flag saying
> whether the year is at the start or the end).
>
> I'm not sure what other ambiguities you'd need to cater for?

Those are basically it. I've played around with doing "intelligent"
parsing, and I'm absolutely against providing hints. If you're
processing a file with dates all in one format, it will frequently
give the wrong answers for a substantial number of them.
In other words, hints don't give your program the capacity
to learn from experiance. Scanning a number of cases and
noting which fields contained numbers > 31 (or 0), or numbers
greater than 12, does.

In any case, there are three formats, and you can't
always depend on a delimiter to tell you where the year
is for 8 digit inputs. Lots of the inputs I've seen have not
had delimiters. On the other hand, a lot of them have
been guaranteed to be in the late 19th century or later.
That's a hint worth having.

John Roth
>
> Paul.
> --
> This signature intentionally left blank



Relevant Pages

  • Re: film vs. digital survival of the hurricane
    ... The second hint is the specific application, ... The file format is Microsoft's Powerpoint v2 for Macintosh. ... explains the lack of a .PPT file ending. ...
    (rec.photo.digital)
  • Re: How to check cluster size
    ... to another drive (would hint on the read performance) ... (format or fully defragment again) ... Capture 15 mins of dv avi file ...
    (microsoft.public.windowsxp.moviemaker)
  • Re: Code instead of copy n paste the conditional format by hand
    ... let me develop it and you or somebody else might start with a hint? ... want to make a check in the cell to the left for that specific row the ... > contitional format ... > with "Sub ...
    (microsoft.public.excel.programming)
  • Re: Awk search multiple lines
    ... > printed in the format: ... Hint: ... Linux solution for data management and processing. ...
    (comp.unix.shell)
  • Re: What happened to the Applescript dictionary in Excel?
    ... I cannot see the file format listed in the Excel 2004 dictionary ... file' from the Microsoft Excel Suite. ... If you use 'custom' then here's a separate 'delimiter' parameter ... That method is not quite correct for saving a single sheet as a tab text ...
    (microsoft.public.mac.office.excel)