开发者

reading recurring events google calendar api

I am developing a front-end application accessible for blind people. I create, delete and update events successfully. My problem is that I want to get the properties of a recurring event, i.e if it's daily, monthly etc, so I can show to my user what the recurring event is and to change it.

The only way I can think of is by parsing the Recurrence string. Though, I find it very difficult and time-consuming. Can anyone think of a different solution开发者_如何学Go to my problem?


If I understand the question correctly, you want to display something like this:

Xyz every day at 5:00 pm starting on 6/1/2011 until 6/6/2011

However, I think this forces you to work backwards based on how recurring events are accessed in the API. All the when properties for the recurring events are stored in a list (e.g., one entry for each day above). In other words, parsing these strings and determining the relation seems the only obvious way to actually determine the relation. It

Reference: http://code.google.com/apis/calendar/data/2.0/developers_guide_dotnet.html

Edit: Actually, it seems that the recurrence string is accessible too, although I can't find it documented online. The CalendarEventEntry class in gdata.calendar.data has the attribute recurrence of the gdata.data.Recurrence class. For reference, here's the comment provided in the function definition in the source file (I'm using the Python version):

class Recurrence(atom.core.XmlElement):
  """The gd:recurrence element.

  Represents the dates and times when a recurring event takes place.

  The string that defines the recurrence consists of a set of properties,
  each of which is defined in the iCalendar standard (RFC 2445).

  Specifically, the string usually begins with a DTSTART property that
  indicates the starting time of the first instance of the event, and
  often a DTEND property or a DURATION property to indicate when the
  first instance ends. Next come RRULE, RDATE, EXRULE, and/or EXDATE
  properties, which collectively define a recurring event and its
  exceptions (but see below). (See section 4.8.5 of RFC 2445 for more
  information about these recurrence component properties.) Last comes a
  VTIMEZONE component, providing detailed timezone rules for any timezone
  ID mentioned in the preceding properties.

  Google services like Google Calendar don't generally generate EXRULE
  and EXDATE properties to represent exceptions to recurring events;
  instead, they generate <gd:recurrenceException> elements. However,
  Google services may include EXRULE and/or EXDATE properties anyway;
  for example, users can import events and exceptions into Calendar, and
  if those imported events contain EXRULE or EXDATE properties, then
  Calendar will provide those properties when it sends a <gd:recurrence>
  element.

  Note the the use of <gd:recurrenceException> means that you can't be
  sure just from examining a <gd:recurrence> element whether there are
  any exceptions to the recurrence description. To ensure that you find
  all exceptions, look for <gd:recurrenceException> elements in the feed,
  and use their <gd:originalEvent> elements to match them up with
  <gd:recurrence> elements.
  """
  ...

Edit 2: Related question, but no answer - Python solution to parse Google calendar's recurrencies.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜