Minor fixes

* Deal with 12:00 AM/PM correctly
* Use UTC in ics output
* :;, don't appear to need escaping
foo
David Bartley 15 years ago
parent 576edd6642
commit b7747c5be0
  1. 12
      scripts/xsltproc.py
  2. 27
      xsl/ics.xsl

@ -1,5 +1,5 @@
#!/usr/bin/python
import os, sys, urllib, libxml2, libxslt, ldap, time, datetime, re
import os, sys, urllib, libxml2, libxslt, ldap, time, datetime, re, pytz
#
# globals
@ -138,11 +138,13 @@ 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':
hour += 12
dt = datetime.datetime(year, month, day, hour, minute)
dt = pytz.timezone('Canada/Eastern').localize(dt)
dt += datetime.timedelta(0, 0, 0, 0, addmin)
return dt.strftime("%Y%m%dT%H%M%S")
return dt.astimezone(pytz.utc).strftime("%Y%m%dT%H%M%SZ")
#
# csc:ical-escape
@ -150,9 +152,9 @@ def cscIcalDatetime(ctx, date, time, addmin = "0"):
def cscIcalEscape(ctx, str):
str = xslArgToString(str)
str = str.replace("\n", " ")
str = str.replace(":", "")
str = str.replace(";", "")
str = str.replace(",", "")
#str = str.replace(":", "")
#str = str.replace(";", "")
#str = str.replace(",", "")
str = re.sub("\s+", " ", str)
str = re.sub("^\s+", "", str)
str = re.sub("\s+$", "", str)

@ -11,31 +11,8 @@ VERSION:2.0
X-WR-CALNAME:University of Waterloo Computer Science Club
PRODID:-//Apple Computer, Inc//iCal 2.0//EN
X-WR-RELCALID:3359A191-B19E-4B53-BADC-DFC084FC51C9
X-WR-TIMEZONE:Canada/Eastern
CALSCALE:GREGORIAN
METHOD:PUBLISH
BEGIN:VTIMEZONE
TZID:Canada/Eastern
LAST-MODIFIED:20060912T200739Z
BEGIN:DAYLIGHT
DTSTART:20060301T070000
TZOFFSETTO:-0400
TZOFFSETFROM:+0000
TZNAME:EDT
END:DAYLIGHT
BEGIN:STANDARD
DTSTART:20061029T020000
TZOFFSETTO:-0500
TZOFFSETFROM:-0400
TZNAME:EST
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:20070311T010000
TZOFFSETTO:-0400
TZOFFSETFROM:-0500
TZNAME:EDT
END:DAYLIGHT
END:VTIMEZONE
<xsl:for-each select="eventitem"><xsl:call-template name="eventitem" /></xsl:for-each>
END:VCALENDAR
</xsl:template>
@ -52,8 +29,8 @@ LOCATION:University of Waterloo - <xsl:value-of select="$room" />
DTSTAMP:20060912T200708Z
UID:<xsl:value-of select="$start" />@csclub.uwaterloo.ca
SEQUENCE:11
DTSTART;TZID=Canada/Eastern:<xsl:value-of select="$start" />
DTEND;TZID=Canada/Eastern:<xsl:value-of select="$end" />
DTSTART:<xsl:value-of select="$start" />
DTEND:<xsl:value-of select="$end" />
SUMMARY:<xsl:value-of select="$title" /><xsl:if test="$short != ''"> -- <xsl:value-of select="$short" /></xsl:if>
DESCRIPTION:<xsl:value-of select="$abstract" />
END:VEVENT

Loading…
Cancel
Save