On Tue, Jun 16, 2009 at 1:52 AM, Michael Anckaert <michael.ancka...@sinax.be
> wrote:

>
> Currently the code is messy to say the least, currently supported
> DATE_FORMAT:
> %d-%m-%Y  16-06-2009
> %Y-%m-%d  2009-06-16
> And all variants where there are one or two day/month digits and/or the -
> delimiter is a /
>
> I intend to make it compatible with all possible DATE_FORMAT options.
>

With Python 2.5, the code for this should be as simple as:
def parse_date(value):
    try:
        return datetime.datetime.strptime(value, settings.DATE_FORMAT)
    except ValueError:
        return False

If we can hold off until that is a dependency of Django, then the code will
be quite pleasant to implement. Before then, it will likely end up as an
ugly hack, probably involving building and compiliing regexes at run-time to
match whatever is in DATE_FORMAT.

-- 
Regards,
Ian Clelland
<clell...@gmail.com>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to