Opened 19 years ago

Closed 19 years ago

Last modified 18 years ago

#207 closed defect (fixed)

TimeFormat seconds function has unused second argument (w/ patch)

Reported by: Mathieu Fenniak <mfenniak@…> 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

Change History (1)

comment:1 by Jacob, 19 years ago

Resolution: fixed
Status: newclosed

(In [313]) Fixed #207 -- thanks, Mathieu.

Note: See TracTickets for help on using tickets.
Back to Top