From phma at phma.optus.nu Thu Sep 29 21:10:20 2011 From: phma at phma.optus.nu (Pierre Abbat) Date: Thu, 29 Sep 2011 15:10:20 -0400 Subject: [icalendar-dev] Generating a report from KTimeTracker data Message-ID: <201109291510.22196.phma@phma.optus.nu> I have a KTimeTracker file with data in iCalendar format of my time spent working on various jobs. I'd like to write a report. So I installed the package (version 2.1 for Python 2.6) and start writing. So far I have this: #!/usr/bin/env python from datetime import datetime from icalendar import UTC,Calendar,Event cal=Calendar.from_string(open("/home/phma/.kde/share/apps/ktimetracker/ktimetracker.ics","rb").read()) cal for component in cal.walk(): if (component.name=="VEVENT"): start=component["DTSTART"] end=component["DTEND"] print component["SUMMARY"],start,end for eventpart in component.walk(): print eventpart I ran it and got a long stream of paragraphs like this: bda 20110928T151930 20110928T164513Z BEGIN:VEVENT CATEGORIES:KTimeTracker CREATED:20110928T191930Z DTEND:20110928T164513Z DTSTAMP:20110928T235906Z DTSTART;TZID=America/New_York:20110928T151930 LAST-MODIFIED:20110928T204514Z RELATED-TO:libkcal-257423038.359 SUMMARY:bda TRANSP:OPAQUE UID:libkcal-1423565012.623 END:VEVENT Next problems I have are: *start and end are of type "instance", not "datetime". How do I get them into a datetime? *The time zone of DTEND of this record is wrong. It should be EDT like DTSTART. I need to convert everything to UTC, since the data were recorded on two computers, and the other one used UTC. Pierre -- sei do'anai mi'a djuno puze'e noroi nalselganse srera