简体   繁体   English

在iOS中为本地时区创建RRULE

[英]Creating RRULE for local timezone in iOS

RRULE requires specific information for when timezone changes between standard and daylight time. RRULE需要时区在标准时间和夏令时之间更改的特定信息。 This information originally comes from the Olson database, and I suspect that it is available in the data property of the NSTimeZone class. 此信息最初来自Olson数据库,我怀疑它在NSTimeZone类的data属性中可用。 But how do I get the structure of this property? 但是,如何获得此属性的结构?

The public methods of NSTimeZone seem insufficient to make a complete RRULE for timezone transitions. NSTimeZone的公共方法似乎不足以为时区转换创建完整的RRULE。

Creating an ical with an RDATE block but not RRULE block results in Exchange complaining of an invalid format. 使用RDATE块而不是RRULE块创建一个ical会导致Exchange抱怨格式无效。

Any suggestions on how to resolve this? 有关如何解决此问题的任何建议?

如果我没有错,那么您可以使用以下代码: https//github.com/FabienDiTore/ios-rrule_parserhttps://github.com/jochenschoellig/RRULE-to-EKRecurrenceRule

I ended up creating a method that uses nextDaylightSavingTransitionAfterDate: to find transition dates a year apart (if they exist). 我最终创建了一个使用nextDaylightSavingTransitionAfterDate:的方法来查找每年相隔一年的过渡日期(如果存在)。 Once these are found, an NSDateComponents object is created for each so the dates can be compared to infer a repeat rule. 找到这些后,将为每个对象创建一个NSDateComponents对象,以便比较日期以推断重复规则。 I considered only matches that occurred in the same month, then checked for either same day number of same day of week. 我只考虑了同月发生的匹配,然后检查了同一天的同一天。 If same day of week, I checked the ordinality of the weekday within the month to create the rule. 如果在一周的同一天,我检查了一个月内工作日的常规来创建规则。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM