#13339: Date(Time)Field.to_python() fails to parse localized month names -------------------------------+-------------------------------------------- Reporter: UloPe | Owner: nobody Status: reopened | Milestone: 1.2 Component: Forms | Version: 1.1 Resolution: | Keywords: i18n l10n Stage: Accepted | Has_patch: 0 Needs_docs: 0 | Needs_tests: 0 Needs_better_patch: 0 | -------------------------------+-------------------------------------------- Comment (by bcurtu):
I have met this problem dealing with Paypal date format ("%H:%M:%S %b %d, %Y PDT" => 12:34:32 Apr 12, 2010 PDT) That's actually an stupid format, but it's paypal so... Anyway, I work with spanish locale, so it crashed. My workaround was really dirty, but it's the only way I got it to work (for django1.1): In django/form/fields.py, in DateTimeField clean method, line 387: {{{ for format in self.input_formats: tmp_value = value try: try: return datetime.datetime(*time.strptime(tmp_value, format)[:6]) except: if '%b' in format: tmp_value = tmp_value.replace('Apr','Abr').replace('Aug','Ago').replace('Dec','Dic').replace('Jan','Ene') #translate here your months :( return datetime.datetime(*time.strptime(tmp_value, format)[:6]) except ValueError: continue }}} -- Ticket URL: <http://code.djangoproject.com/ticket/13339#comment:8> Django <http://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-upda...@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.