From be3bc2bc00c60a3ed78d8fd738afa47ea95a7a11 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Thu, 28 Feb 2008 19:50:08 -0500 Subject: [PATCH] manually "cherry picked" f6639981: Fixed "Feb 29" bug. Thanks to James Andrewartha who pointed this out. Thanks to Yaroslav Halchenko for the fix. --- server/datestrptime.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/server/datestrptime.py b/server/datestrptime.py index 1adec250..2fefa5fd 100644 --- a/server/datestrptime.py +++ b/server/datestrptime.py @@ -72,7 +72,14 @@ class DateStrptime(DateTemplate): except ValueError: # Try to convert date string to 'C' locale conv = self.convertLocale(dateMatch.group()) - date = list(time.strptime(conv, self.getPattern())) + try: + date = list(time.strptime(conv, self.getPattern())) + except ValueError: + # Try to add the current year to the pattern. Should fix + # the "Feb 29" issue. + conv += " %s" % MyTime.gmtime()[0] + pattern = "%s %%Y" % self.getPattern() + date = list(time.strptime(conv, pattern)) if date[0] < 2000: # There is probably no year field in the logs date[0] = MyTime.gmtime()[0]