Shitty hack to attempt to deal with 24-hour times properly in the future.
authorMichael Gregson <mgregson@csclub.uwaterloo.ca>
Wed, 17 Jun 2009 05:35:05 +0000 (23:35 -0600)
committerMichael Gregson <mgregson@csclub.uwaterloo.ca>
Wed, 17 Jun 2009 05:35:05 +0000 (23:35 -0600)
scripts/xsltproc.py

index 08c1f01..2e26647 100755 (executable)
@@ -139,9 +139,18 @@ def cscIcalDatetime(ctx, date, time, addmin = "0"):
     hour, minute = (0, 0)
     if r != None:
         hour, minute = (int(i) for i in r.groups()[:2])
-        hour %= 12 #hour % 12
-        if r.group(3) in 'pP':
+
+        # 12-hour times
+        if r.group(3) in 'aA':
+            hour %= 12 #hour % 12
+        elif r.group(3) in 'pP':
+            hour %= 12
             hour += 12
+
+        # 24-hour time
+        else:
+            hour %= 24
+            
     dt = datetime.datetime(year, month, day, hour, minute)
     dt = pytz.timezone('Canada/Eastern').localize(dt)
     dt += datetime.timedelta(0, 0, 0, 0, addmin)