[uf-discuss] Fwd: vobject and hcalendar
Dr. Ernie Prabhakar
drernie at opendarwin.org
Tue Sep 5 15:47:04 PDT 2006
Hi all,
Jeffrey Harris from OSAF was kind enough to point me to the hCalendar
support in top-of-tree of vobject:
> <http://svn.osafoundation.org/vobject/trunk/>
Specifically, this class:
http://svn.osafoundation.org/vobject/trunk/src/vobject/hcalendar.py
Anybody feel like testing it out and/or improving it? From what I
can see, it works pretty well for the basic cases. FYI, here's the
doctest for it.
-- Ernie P.
http://svn.osafoundation.org/vobject/trunk/tests/tests.py
"Serializing iCalendar to hCalendar" :
"""
>>> cal = base.newFromBehavior('hcalendar')
>>> cal.behavior
<class 'hcalendar.HCalendar'>
>>> pacific = dateutil.tz.tzical(StringIO.StringIO
(timezones)).get('US/Pacific')
>>> cal.add('vevent')
<VEVENT| []>
>>> cal.vevent.add('summary').value = "this is a note"
>>> cal.vevent.add('url').value = "http://microformats.org/code/
hcalendar/creator"
>>> cal.vevent.add('dtstart').value = datetime.date(2006,2,27)
>>> cal.vevent.add('location').value = "a place"
>>> cal.vevent.add('dtend').value = datetime.date(2006,2,27) +
datetime.timedelta(days = 2)
>>> event2 = cal.add('vevent')
>>> event2.add('summary').value = "Another one"
>>> event2.add('description').value = "The greatest thing ever!"
>>> event2.add('dtstart').value = datetime.datetime(1998, 12,
17, 16, 42, tzinfo = pacific)
>>> event2.add('location').value = "somewhere else"
>>> event2.add('dtend').value = event2.dtstart.value +
datetime.timedelta(days = 6)
>>> hcal = cal.serialize()
>>> print hcal
<span class="vevent">
<a class="url" href="http://microformats.org/code/hcalendar/
creator">
<span class="summary">this is a note</span>:
<abbr class="dtstart", title="20060227">Monday, February
27</abbr>
- <abbr class="dtend", title="20060301">Tuesday, February
28</abbr>
at <span class="location">a place</span>
</a>
</span>
<span class="vevent">
<span class="summary">Another one</span>:
<abbr class="dtstart", title="19981217T164200-0800">Thursday,
December 17, 16:42</abbr>
- <abbr class="dtend",
title="19981223T164200-0800">Wednesday, December 23, 16:42</abbr>
at <span class="location">somewhere else</span>
<div class="description">The greatest thing ever!</div>
</span>
""",
More information about the microformats-discuss
mailing list