#207 closed defect (fixed)
TimeFormat seconds function has unused second argument (w/ patch)
| Reported by: | Owned by: | Adrian Holovaty | |
|---|---|---|---|
| Component: | Template system | Version: | |
| Severity: | normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
When using a time format with the 's' format string, which should be the time's seconds with leading zeros, the following error occurs:
File "/usr/lib/python2.3/site-packages/django/core/defaultfilters.py", line 329, in time
return time_format(value, arg)
File "/usr/lib/python2.3/site-packages/django/utils/dateformat.py", line 317, in time_format
return tf.format(format_string)
File "/usr/lib/python2.3/site-packages/django/utils/dateformat.py", line 304, in format
result += str(getattr(self, char)())
TypeError: s() takes exactly 2 arguments (1 given)
It seems that the TimeFormat's s function has an unnecessary and harmful second argument that is never used. This simple patch addresses the problem:
Index: django/utils/dateformat.py
===================================================================
--- django/utils/dateformat.py (revision 312)
+++ django/utils/dateformat.py (working copy)
@@ -293,7 +293,7 @@
return 'noon'
return '%s %s' % (self.f(), self.a())
- def s(self, s):
+ def s(self):
"Seconds; i.e. '00' to '59'"
return '%02d' % self.time.second
Note:
See TracTickets
for help on using tickets.
(In [313]) Fixed #207 -- thanks, Mathieu.