Opened 18 years ago
Closed 16 years ago
#4927 closed defect (fixed)
DD/MM/YY is not a known date format.
Reported by: | Mishu | Owned by: | Christopher Lenz |
---|---|---|---|
Priority: | low | Milestone: | 0.11 |
Component: | admin/web | Version: | |
Severity: | normal | Keywords: | |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description (last modified by )
In the module for Adding milestones if you type the due date in the format DD/MM/YY TRAC sends the next message:
Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/trac/web/main.py", line 387, in dispatch_request dispatcher.dispatch(req) File "/usr/lib/python2.4/site-packages/trac/web/main.py", line 237, in dispatch resp = chosen_handler.process_request(req) File "/usr/lib/python2.4/site-packages/TracWebAdmin-0.1.2dev_r4429-py2.4.egg/webadmin/web_ui.py", line 109, in process_request path_info) File "/usr/lib/python2.4/site-packages/TracWebAdmin-0.1.2dev_r4429-py2.4.egg/webadmin/ticket.py", line 163, in process_admin_request mil.due = util.parse_date(req.args.get('duedate')) File "/usr/lib/python2.4/site-packages/trac/util/datefmt.py", line 114, in parse_date raise ValueError, '%s is not a known date format.' % text ValueError: 22/03/07 is not a known date format.
Attachments (0)
Change History (8)
comment:1 by , 18 years ago
Description: | modified (diff) |
---|---|
Milestone: | none |
comment:2 by , 18 years ago
Hi, I came across the same error today. I'm using 10.3 with webadmin version 0.1.2dev_r4240-py2.4. Regardless of what the format of the date should be, it might be nice to have a nicely formated error message returned rather than the traceback.
Regards, Clint
comment:3 by , 18 years ago
It seems that with several locales, Python refuses to parse years without a century, that is the expected format would be DD/MM/YYYY
whereas DD/MM/YY
would actually be rejected.
I'm still interested in knowing the locale you used to get DD/MM/YY
as the expected format.
comment:4 by , 18 years ago
Quick patch to get rid of the traceback and obtain a hint about the expected date format:
-
trac/util/datefmt.py
23 23 import time 24 24 from datetime import tzinfo, timedelta, datetime 25 25 from trac.util.text import to_unicode 26 from trac.core import TracError 26 27 27 28 # Date/time utilities 28 29 … … 149 150 except ValueError: 150 151 continue 151 152 if tm == None: 152 raise ValueError('%s is invalid or not a known date format' % text) 153 hint = get_date_format_hint() 154 raise TracError('%s is invalid or not a known date format, ' 155 'try %s' % (text, hint), 'Invalid date') 153 156 return datetime(*(tm[0:6] + (0, tzinfo))) 154 157 155 158 def to_timestamp(dt):
comment:5 by , 18 years ago
Milestone: | → 0.11 |
---|
Manu, sorry for the late reply, but your change looks good. I had a pending change there (related to this bug and #4530), but I modified it in favor of your change, as raising directly a TracError
instead of a ValueError
is actually much simpler than wrapping every call of parse_date in an exception handler that will catch ValueError and re-raise a TracError, as we already did in several places.
comment:6 by , 18 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Modified patch applied in r5188. This changeset also contains the related simplifications due to the ValueError
→ TracError
change.
follow-up: 8 comment:7 by , 16 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
On the demo site (http://www.hosted-projects.com/trac/TracDemo/Demo) this bug still occurs when adding a milestone (http://www.hosted-projects.com/trac/TracDemo/Demo/admin/ticket/milestones).
Enter a date e.g. 02/30/09 (an invalid date). The expected result is that it doesn't give a traceback but rather a user-friendly warning.
Python Traceback
Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/trac/web/main.py", line 406, in dispatch_request
dispatcher.dispatch(req)
File "/usr/lib/python2.5/site-packages/trac/web/main.py", line 237, in dispatch
resp = chosen_handler.process_request(req)
File "/usr/lib/python2.5/site-packages/TracWebAdmin-0.1.2dev-py2.5.egg/webadmin/web_ui.py", line 119, in process_request
path_info)
File "/usr/lib/python2.5/site-packages/TracWebAdmin-0.1.2dev-py2.5.egg/webadmin/ticket.py", line 163, in process_admin_request
mil.due = util.parse_date(req.args.get('duedate'))
File "/usr/lib/python2.5/site-packages/trac/util/datefmt.py", line 114, in parse_date
raise ValueError, '%s is not a known date format.' % text
ValueError: 02/40/09 is not a known date format.
comment:8 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Please specifiy which release of Trac you use. Have you defined any locale?