>
> 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.
>

Never mind that; in 2.3, the code is almost as simple -- and forwards
compatible, too:

import datetime
import time

def parse_date(value):
    try:
        return datetime.date(*time.strptime(value,settings.DATE_FORMAT)[:3])
    except ValueError:
        return False

It is probably worth discussing, though, whether the output and input date
formats should always be the same, or if there is value in letting them
differ (especially if someone has set DATE_FORMAT to something like '%b %d,
%Y AD'). There may even be output formats that are not usable as input
formats at all.

Perhaps a DATE_INPUT_FORMAT setting, which defaults if unset to DATE_FORMAT,
would be more appropriate.

-- 
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