Never been to DZone Snippets before?

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

Calendar module (See related posts)

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)

   1  
   2  import time, calendar
   3  now = time.time()
   4  cal = calendar.open()
   5  
   6  day_all = cal.daily_instances(now) # all entries today
   7  # if you specify any of the 4 types, it will show only those
   8  month_ev = cal.monthly_instances(now, events=1) # events this month
   9  # search for keyword within duration
  10  jan01 = mktime((2005,1,1, 0,0,0, 0,0,0))
  11  first_km = cal.find_instances(jan01, now, u'km')[0] # first in this year
  12  
  13  # display entry information
  14  e = cal[first_km['id']] # or use any entry found above
  15  print e.type, strftime('%b %d %H:%M', localtime(e.start_time))
  16  print e.content, '(', e.location, ')'
  17  # other properties are id, last_modified, priority, alarm,
  18  #  replication, crossed_out, and end_time
  19  
  20  # add new appointment
  21  a = cal.add_appointment()
  22  a.content = 'urgent meeting'
  23  a.set_time(now, now) # start and end time
  24  a.commit() 

There's a bug with find_instances. It return only 1 matching entry. (should return all)

You need to create an account or log in to post comments to this site.


Click here to browse all 5309 code snippets

Related Posts