Django

Code

Ticket #742 (closed: fixed)

Opened 3 years ago

Last modified 2 years ago

history raises error in datetime while using non english language

Reported by: radek <translate@svarz.cz> Assigned to: adrian
Milestone: Component: Core framework
Version: 1.0 Keywords:
Cc: Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

I slightly polished dateformat.py, which was the reason of rasing error in Admin/history, when using different locale settings.

Patch:

Index: C:/Python24/Lib/site-packages/django/utils/dateformat.py
===================================================================
--- C:/Python24/Lib/site-packages/django/utils/dateformat.py	(revision 1092)
+++ C:/Python24/Lib/site-packages/django/utils/dateformat.py	(working copy)
@@ -14,6 +14,7 @@
 from django.utils.dates import MONTHS, MONTHS_AP, WEEKDAYS
 from django.utils.tzinfo import LocalTimezone
 from calendar import isleap
+from calendar import monthrange
 import re, time
 
 re_formatchars = re.compile(r'(?<!\\)([aABdDfFgGhHiIjlLmMnNOPrsStTUwWyYzZ])')
@@ -124,10 +125,6 @@
 
     def I(self):
         "'1' if Daylight Savings Time, '0' otherwise."
-        raise NotImplementedError
-
-    def I(self):
-        "'1' if Daylight Savings Time, '0' otherwise."
         if self.timezone.dst(self.data):
             return '1'
         else:
@@ -185,7 +182,8 @@
 
     def t(self):
         "Number of days in the given month; i.e. '28' to '31'"
-        raise NotImplementedError
+        num = monthrange(self.data.year, self.data.month)[1]
+        return '%02d' % num
 
     def T(self):
         "Time zone of this machine; e.g. 'EST' or 'MDT'" 

Attachments

Change History

11/06/05 17:53:14 changed by adrian

  • status changed from new to closed.
  • resolution set to fixed.

(In [1116]) Fixed #742 -- Implemented 't' dateformat. Thanks, radek.

04/24/06 16:31:17 changed by ruben.perez@gmail.com

  • status changed from closed to reopened.
  • resolution deleted.

Hi, this issue is not working with languages like es, es-es, es-mx, etc... The output is something like this: "LunAMCESTE_171CEST03_CEST1AbrE_Abril1146273358FalseFalse" instead of "24 de Abril, 2006, 3:15 a.m.". I´ve checked my dateformat.py and it is the same like yours.

Thank You Very Much.

05/21/06 21:11:21 changed by adrian

  • status changed from reopened to closed.
  • resolution set to fixed.

Closing this ticket. Please reopen with more information if it's still a problem.

01/17/07 16:12:17 changed by

  • milestone deleted.

Milestone Version 1.0 deleted


Add/Change #742 (history raises error in datetime while using non english language)




Change Properties
Action