Commit f0899767 authored by Aurel's avatar Aurel Committed by Jérome Perrin

some DateTime variable are moved to module constant

parent c3858e2d
...@@ -89,6 +89,7 @@ DateTimeKlass.__getstate__ = DateTime__getstate__ ...@@ -89,6 +89,7 @@ DateTimeKlass.__getstate__ = DateTime__getstate__
def DateTime_parse(self, st, datefmt=getDefaultDateFormat()): def DateTime_parse(self, st, datefmt=getDefaultDateFormat()):
# Parse date-time components from a string # Parse date-time components from a string
month=year=tz=tm=None month=year=tz=tm=None
try: # BBB DateTime 2.12
spaces =self.space_chars spaces =self.space_chars
intpat =self.int_pattern intpat =self.int_pattern
fltpat =self.flt_pattern fltpat =self.flt_pattern
...@@ -97,8 +98,19 @@ def DateTime_parse(self, st, datefmt=getDefaultDateFormat()): ...@@ -97,8 +98,19 @@ def DateTime_parse(self, st, datefmt=getDefaultDateFormat()):
MonthNumbers =self._monthmap MonthNumbers =self._monthmap
DayOfWeekNames=self._daymap DayOfWeekNames=self._daymap
ValidZones =self._tzinfo._zidx ValidZones =self._tzinfo._zidx
_MONTH_LEN = self._month_len
except AttributeError:
from DateTime.DateTime import (SPACE_CHARS as spaces,
INT_PATTERN as intpat,
FLT_PATTERN as fltpat,
NAME_PATTERN as wordpat,
DELIMITERS as delimiters,
_MONTHMAP as MonthNumbers,
_DAYMAP as DayOfWeekNames,
_TZINFO,
_MONTH_LEN)
ValidZones = _TZINFO._zidx
TimeModifiers =['am','pm'] TimeModifiers =['am','pm']
# Find timezone first, since it should always be the last # Find timezone first, since it should always be the last
# element, and may contain a slash, confusing the parser. # element, and may contain a slash, confusing the parser.
st= st.strip() st= st.strip()
...@@ -236,10 +248,9 @@ def DateTime_parse(self, st, datefmt=getDefaultDateFormat()): ...@@ -236,10 +248,9 @@ def DateTime_parse(self, st, datefmt=getDefaultDateFormat()):
year = _correctYear(year) year = _correctYear(year)
#handle dates before year 1000 #handle dates before year 1000
#if year < 1000: raise SyntaxError, st #if year < 1000: raise SyntaxError, st
leap = year%4==0 and (year%100!=0 or year%400==0) leap = year%4==0 and (year%100!=0 or year%400==0)
try: try:
if not day or day > self._month_len[leap][month]: if not day or day > _MONTH_LEN[leap][month]:
raise DateError(st) raise DateError(st)
except IndexError: except IndexError:
raise DateError(st) raise DateError(st)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment