[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[minion-cvs] Remove support for obsolete date format
Update of /home/minion/cvsroot/src/minion/lib/mixminion
In directory moria.mit.edu:/tmp/cvs-serv10518/src/minion/lib/mixminion
Modified Files:
Config.py test.py
Log Message:
Remove support for obsolete date format
Index: Config.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Config.py,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -d -r1.86 -r1.87
--- Config.py 2 May 2004 18:45:15 -0000 1.86
+++ Config.py 18 May 2004 02:55:14 -0000 1.87
@@ -384,25 +384,24 @@
raise ConfigError("Invalid date %r"%s)
return calendar.timegm((yyyy,MM,dd,0,0,0,0,0,0))
-# FFFF008 stop accepting YYYY/MM/DD
-# Regular expression to match YYYY/MM/DD HH:MM:SS
-_time_re = re.compile(r"^(\d\d\d\d)([/-])(\d\d)([/-])(\d\d)\s+"
+# Regular expression to match YYYY-MM-DD HH:MM:SS
+_time_re = re.compile(r"^(\d\d\d\d)-(\d\d)-(\d\d)\s+"
r"(\d\d):(\d\d):(\d\d)((?:\.\d\d\d)?)$")
def _parseTime(s):
"""Validation function. Converts from YYYY/MM/DD HH:MM:SS format
to a (float) time value for GMT."""
m = _time_re.match(s.strip())
- if not m or m.group(2) != m.group(4):
- raise ConfigError("Invalid time %r" % s)
+ if not m:
+ raise ConfigError("Invalid format for time")
yyyy = int(m.group(1))
- MM = int(m.group(3))
- dd = int(m.group(5))
- hh = int(m.group(6))
- mm = int(m.group(7))
- ss = int(m.group(8))
- if m.group(9):
- fsec = float(m.group(9))
+ MM = int(m.group(2))
+ dd = int(m.group(3))
+ hh = int(m.group(4))
+ mm = int(m.group(5))
+ ss = int(m.group(6))
+ if m.group(7):
+ fsec = float(m.group(7))
else:
fsec = 0.0
Index: test.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/test.py,v
retrieving revision 1.199
retrieving revision 1.200
diff -u -d -r1.199 -r1.200
--- test.py 17 May 2004 22:39:17 -0000 1.199
+++ test.py 18 May 2004 02:55:14 -0000 1.200
@@ -4507,7 +4507,7 @@
tm = C._parseDate("2000-05-03")
self.assertEquals(time.gmtime(tm)[:6], (2000,5,3,0,0,0))
# Time
- tm = C._parseTime("2001/12/25 06:15:10")
+ tm = C._parseTime("2001-12-25 06:15:10")
self.assertEquals(time.gmtime(tm)[:6], (2001,12,25,6,15,10))
tm = C._parseTime("2001-12-25 06:15:10.623")
self.assertEquals(time.gmtime(tm)[:6], (2001,12,25,6,15,10))
@@ -4577,12 +4577,12 @@
fails(C._parseDate, "2000/1/1")
fails(C._parseDate, "2000/10-10")
fails(C._parseDate, "2000-10/10")
- fails(C._parseDate, "2000/50/01")
- fails(C._parseDate, "2000/50/01 12:12:12")
- fails(C._parseTime, "2000/50-01 12:12:12")
- fails(C._parseDate, "2000-50/01 12:12:12")
+ fails(C._parseDate, "2000-50-01")
+ fails(C._parseDate, "2000/20/01 12:12:12")
+ fails(C._parseTime, "2000/50/01 12:12:12")
+ fails(C._parseDate, "2000/20/01 12:12:12")
fails(C._parseDate, "2000-50-01 12:12:12.3")
- fails(C._parseTime, "2000/50/01 12:12:99")
+ fails(C._parseTime, "2000-20-01 12:12:99")
fails(C._parseNickname, "Mrs Premise")
fails(C._parseNickname, "-Mrs-Premise")
fails(C._parseNickname, "../../../AllYourBase")