DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Calendar Module

  • submit to reddit
        py_s60 1.1.3 provides calendar module where you can manipulate
your calendar and todo items. Many item types (called entry) are
contained in the calendar. They are
- Appointment
- Event
- Aniversary
- Todo
There is also a TodoList type to group each TodoEntry 
into many lists.

Since the official document (a programming guide) is not 
finished yet, I will just shown some simple tasks.
(I don't have time to try everything)

import time, calendar
now = time.time()
cal =

day_all = cal.daily_instances(now) # all entries today
# if you specify any of the 4 types, it will show only those
month_ev = cal.monthly_instances(now, events=1) # events this month
# search for keyword within duration
jan01 = mktime((2005,1,1, 0,0,0, 0,0,0))
first_km = cal.find_instances(jan01, now, u'km')[0] # first in this year

# display entry information
e = cal[first_km['id']] # or use any entry found above
print e.type, strftime('%b %d %H:%M', localtime(e.start_time))
print e.content, '(', e.location, ')'
# other properties are id, last_modified, priority, alarm,
#  replication, crossed_out, and end_time

# add new appointment
a = cal.add_appointment()
a.content = 'urgent meeting'
a.set_time(now, now) # start and end time
There's a bug with find_instances. It return only 1 matching entry. (should return all)