From sal at stodge.org Sat Apr 5 13:46:05 2008 From: sal at stodge.org (Salim Fadhley) Date: Sat, 5 Apr 2008 12:46:05 +0100 Subject: [icalendar-dev] How to make a now & next application with an iCal feed Message-ID: I have an iCalendar feed that represents the schedule of a broadcast radio station. I'd like to perform some sort of query on this feed to tell me what the current program is and what program will be starting next. I've managed to use the icalendar class to iterate over the event objects in the file, however is there a convenient way to query the object so that I only get objects for which the start and end time is between a time-range? The issue I have is repeating elements - most items in the calendar are repeating elements - so one object might actually represent a whole range of show instances in the schedule - how do I be sure I am not missing one. Here is my public iCal: http://www.google.com/calendar/ical/schedule%40resonancefm.com/public/basic.ics Thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://codespeak.net/pipermail/icalendar-dev/attachments/20080405/01de1927/attachment.htm From matt-icalendar at mosuki.com Mon Apr 7 08:28:39 2008 From: matt-icalendar at mosuki.com (Matt Chisholm) Date: Sun, 6 Apr 2008 23:28:39 -0700 Subject: [icalendar-dev] How to make a now & next application with an iCal feed In-Reply-To: References: Message-ID: <20080407062839.GK796@devsuki.com> iCalendar is just a data-interchange format, and all the iCalendar Python package does is translate between that format and Python objects. You'll have to implement querying for the next instance of a repeating event yourself. (Or there might be another Python library that does it.) -matt On Apr 5 2008, 12:46, Salim Fadhley wrote: >I have an iCalendar feed that represents the schedule of a broadcast radio >station. I'd like to perform some sort of query on this feed to tell me what >the current program is and what program will be starting next. > >I've managed to use the icalendar class to iterate over the event objects in >the file, however is there a convenient way to query the object so that I only >get objects for which the start and end time is between a time-range? > >The issue I have is repeating elements - most items in the calendar are >repeating elements - so one object might actually represent a whole range of >show instances in the schedule - how do I be sure I am not missing one. > >Here is my public iCal: >http://www.google.com/calendar/ical/schedule%40resonancefm.com/public/basic.ics > >Thanks! > > > >_______________________________________________ >icalendar-dev mailing list >icalendar-dev at codespeak.net >http://codespeak.net/mailman/listinfo/icalendar-dev From thomas at tuxpeople.org Mon Apr 7 12:30:10 2008 From: thomas at tuxpeople.org (Thomas E. Deutsch) Date: Mon, 07 Apr 2008 12:30:10 +0200 Subject: [icalendar-dev] How to specify a UTC offset Message-ID: <47F9F7B2.2070900@tuxpeople.org> Hello I've created following script, to merge multiple iCals into one. But I've a problem. I need to specify a UTC offset, 'cause Sundbird has problems mit some of the events without it. Can someone give me a hint how to do this? Oh, and if you see another thing I've forgot, feel free to tell me :) Thanks, Thomas import glob, sys from icalendar import Calendar, Event, Timezone newcal = Calendar() newcal.add('prodid', '-//' + MY_NAME + '//' + MY_DOMAIN + '//') newcal.add('version', '2.0') newcal.add('x-wr-calname', CALENDARNAME) newcal.add('X-WR-TIMEZONE', 'Europe/Zurich') newtimezone = Timezone() newtimezone.add('tzid', "Europe/Zurich") newcal.add_component(newtimezone) for s in glob.glob(CALDIR + '*.ics'): try: calfile = open(s,'rb') cal = Calendar.from_string(calfile.read()) for component in cal.subcomponents: if component.name == 'VEVENT': newcal.add_component(component) calfile.close() except: print MY_SHORTNAME + ": Error: reading file:", sys.exc_info()[1] print s try: f = open(ICS_OUT, 'wb') f.write(newcal.as_string()) f.close() except: print MY_SHORTNAME + ": Error: ", sys.exc_info()[1] From cmclaughlin at atlassian.com Thu Apr 17 03:11:24 2008 From: cmclaughlin at atlassian.com (Charles McLaughlin) Date: Wed, 16 Apr 2008 18:11:24 -0700 Subject: [icalendar-dev] timezones Message-ID: <4806A3BC.40305@atlassian.com> Hi, I'd love some advise on the best way to shift timezones. I've attached some code below. I'm new to this package and haven't dealt with date and time in Python much. I have have an entry in my ics file that is in another time zone. I want to convert it to US pacific time or the timezone of the localhost. Does the iCalendar package provide any methods for extracting dtstart and dtend in local time? Or should I just use standard Python packages for this? Thanks, Charles -------- from icalendar import Calendar, Event, vDatetime cal = Calendar.from_string(open('cal.ics','rb').read()) for event in cal.walk('vevent'): print "Date Start: " dtstart = vDatetime.from_ical(str(event['dtstart'])) print dtstart print event['dtstart'].params # prints time zone info The event I want to shift to local time is: Date Start: 2007-12-05 11:00:00 TZID=(GMT+10.00) Canberra / Melbourne / Sydney