<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: pim code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sat, 06 Sep 2008 19:07:28 GMT</pubDate>
    <description>DZone Snippets: pim code</description>
    <item>
      <title>Calendar module</title>
      <link>http://snippets.dzone.com/posts/show/402</link>
      <description>py_s60 1.1.3 provides calendar module where you can manipulate&lt;br /&gt;your calendar and todo items. Many item types (called entry) are&lt;br /&gt;contained in the calendar. They are&lt;br /&gt;- Appointment&lt;br /&gt;- Event&lt;br /&gt;- Aniversary&lt;br /&gt;- Todo&lt;br /&gt;There is also a TodoList type to group each TodoEntry &lt;br /&gt;into many lists.&lt;br /&gt;&lt;br /&gt;Since the official document (a programming guide) is not &lt;br /&gt;finished yet, I will just shown some simple tasks.&lt;br /&gt;(I don't have time to try everything)&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;import time, calendar&lt;br /&gt;now = time.time()&lt;br /&gt;cal = calendar.open()&lt;br /&gt;&lt;br /&gt;day_all = cal.daily_instances(now) # all entries today&lt;br /&gt;# if you specify any of the 4 types, it will show only those&lt;br /&gt;month_ev = cal.monthly_instances(now, events=1) # events this month&lt;br /&gt;# search for keyword within duration&lt;br /&gt;jan01 = mktime((2005,1,1, 0,0,0, 0,0,0))&lt;br /&gt;first_km = cal.find_instances(jan01, now, u'km')[0] # first in this year&lt;br /&gt;&lt;br /&gt;# display entry information&lt;br /&gt;e = cal[first_km['id']] # or use any entry found above&lt;br /&gt;print e.type, strftime('%b %d %H:%M', localtime(e.start_time))&lt;br /&gt;print e.content, '(', e.location, ')'&lt;br /&gt;# other properties are id, last_modified, priority, alarm,&lt;br /&gt;#  replication, crossed_out, and end_time&lt;br /&gt;&lt;br /&gt;# add new appointment&lt;br /&gt;a = cal.add_appointment()&lt;br /&gt;a.content = 'urgent meeting'&lt;br /&gt;a.set_time(now, now) # start and end time&lt;br /&gt;a.commit() &lt;br /&gt;&lt;/code&gt;&lt;br /&gt;There's a bug with find_instances. It return only 1 matching entry. (should return all)</description>
      <pubDate>Mon, 20 Jun 2005 01:32:04 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/402</guid>
      <author>korakot (Korakot Chaovavanich)</author>
    </item>
  </channel>
</rss>
