Opened 13 years ago

Closed 13 years ago

Last modified 12 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


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/", line 329, in time
    return time_format(value, arg)

  File "/usr/lib/python2.3/site-packages/django/utils/", line 317, in time_format
    return tf.format(format_string)

  File "/usr/lib/python2.3/site-packages/django/utils/", 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/
--- django/utils/  (revision 312)
+++ django/utils/  (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 Changed 13 years ago by Jacob

Resolution: fixed
Status: newclosed

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

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