我正在开发一个可供盲人使用的前端应用程序。我成功创建,删除和更新events
。我的问题是我想获得一个 recurring 的属性event
,即如果它是每天,每月等,所以我可以向我的用户显示重复event
是什么并更改它。
我能想到的唯一方法是解析Recurrence
字符串。不过,我觉得这非常困难且耗时。谁能想到我的问题的不同解决方案?
我正在开发一个可供盲人使用的前端应用程序。我成功创建,删除和更新events
。我的问题是我想获得一个 recurring 的属性event
,即如果它是每天,每月等,所以我可以向我的用户显示重复event
是什么并更改它。
我能想到的唯一方法是解析Recurrence
字符串。不过,我觉得这非常困难且耗时。谁能想到我的问题的不同解决方案?
如果我正确理解了这个问题,您希望显示如下内容:
Xyz every day at 5:00 pm starting on 6/1/2011 until 6/6/2011
但是,我认为这会迫使您根据 API 中重复事件的访问方式向后工作。重复事件的所有when
属性都存储在一个列表中(例如,上面的每一天都有一个条目)。换句话说,解析这些字符串并确定关系似乎是实际确定关系的唯一明显方法。它
参考:http ://code.google.com/apis/calendar/data/2.0/developers_guide_dotnet.html
编辑:实际上,似乎重复字符串也可以访问,尽管我在网上找不到它的文档。中的CalendarEventEntry
类gdata.calendar.data
具有类的属性。作为参考,这是源文件中函数定义中提供的注释(我使用的是 Python 版本):recurrence
gdata.data.Recurrence
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.
"""
...
编辑 2:相关问题,但没有答案 - Python 解决方案来解析 Google 日历的递归。