miguelbaldi-ri_cal 0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. data/History.txt +156 -0
  2. data/Manifest.txt +161 -0
  3. data/README.txt +410 -0
  4. data/Rakefile +53 -0
  5. data/bin/ri_cal +8 -0
  6. data/component_attributes/alarm.yml +10 -0
  7. data/component_attributes/calendar.yml +4 -0
  8. data/component_attributes/component_property_defs.yml +180 -0
  9. data/component_attributes/event.yml +45 -0
  10. data/component_attributes/freebusy.yml +16 -0
  11. data/component_attributes/journal.yml +35 -0
  12. data/component_attributes/timezone.yml +3 -0
  13. data/component_attributes/timezone_period.yml +11 -0
  14. data/component_attributes/todo.yml +46 -0
  15. data/copyrights.txt +1 -0
  16. data/docs/draft-ietf-calsify-2446bis-08.txt +7280 -0
  17. data/docs/draft-ietf-calsify-rfc2445bis-09.txt +10416 -0
  18. data/docs/incrementers.txt +7 -0
  19. data/docs/rfc2445.pdf +0 -0
  20. data/lib/ri_cal.rb +187 -0
  21. data/lib/ri_cal/component.rb +253 -0
  22. data/lib/ri_cal/component/alarm.rb +19 -0
  23. data/lib/ri_cal/component/calendar.rb +257 -0
  24. data/lib/ri_cal/component/event.rb +58 -0
  25. data/lib/ri_cal/component/freebusy.rb +16 -0
  26. data/lib/ri_cal/component/journal.rb +27 -0
  27. data/lib/ri_cal/component/non_standard.rb +33 -0
  28. data/lib/ri_cal/component/t_z_info_timezone.rb +139 -0
  29. data/lib/ri_cal/component/timezone.rb +197 -0
  30. data/lib/ri_cal/component/timezone/daylight_period.rb +25 -0
  31. data/lib/ri_cal/component/timezone/standard_period.rb +23 -0
  32. data/lib/ri_cal/component/timezone/timezone_period.rb +76 -0
  33. data/lib/ri_cal/component/todo.rb +42 -0
  34. data/lib/ri_cal/core_extensions.rb +11 -0
  35. data/lib/ri_cal/core_extensions/array.rb +7 -0
  36. data/lib/ri_cal/core_extensions/array/conversions.rb +15 -0
  37. data/lib/ri_cal/core_extensions/date.rb +13 -0
  38. data/lib/ri_cal/core_extensions/date/conversions.rb +69 -0
  39. data/lib/ri_cal/core_extensions/date_time.rb +15 -0
  40. data/lib/ri_cal/core_extensions/date_time/conversions.rb +55 -0
  41. data/lib/ri_cal/core_extensions/object.rb +8 -0
  42. data/lib/ri_cal/core_extensions/object/conversions.rb +20 -0
  43. data/lib/ri_cal/core_extensions/string.rb +8 -0
  44. data/lib/ri_cal/core_extensions/string/conversions.rb +53 -0
  45. data/lib/ri_cal/core_extensions/time.rb +14 -0
  46. data/lib/ri_cal/core_extensions/time/calculations.rb +153 -0
  47. data/lib/ri_cal/core_extensions/time/conversions.rb +42 -0
  48. data/lib/ri_cal/core_extensions/time/tzid_access.rb +50 -0
  49. data/lib/ri_cal/core_extensions/time/week_day_predicates.rb +55 -0
  50. data/lib/ri_cal/fast_date_time.rb +226 -0
  51. data/lib/ri_cal/floating_timezone.rb +32 -0
  52. data/lib/ri_cal/invalid_property_value.rb +8 -0
  53. data/lib/ri_cal/invalid_timezone_identifier.rb +20 -0
  54. data/lib/ri_cal/occurrence_enumerator.rb +265 -0
  55. data/lib/ri_cal/occurrence_period.rb +17 -0
  56. data/lib/ri_cal/parser.rb +145 -0
  57. data/lib/ri_cal/properties.rb +12 -0
  58. data/lib/ri_cal/properties/alarm.rb +390 -0
  59. data/lib/ri_cal/properties/calendar.rb +164 -0
  60. data/lib/ri_cal/properties/event.rb +1526 -0
  61. data/lib/ri_cal/properties/freebusy.rb +594 -0
  62. data/lib/ri_cal/properties/journal.rb +1240 -0
  63. data/lib/ri_cal/properties/timezone.rb +151 -0
  64. data/lib/ri_cal/properties/timezone_period.rb +416 -0
  65. data/lib/ri_cal/properties/todo.rb +1562 -0
  66. data/lib/ri_cal/property_value.rb +159 -0
  67. data/lib/ri_cal/property_value/array.rb +27 -0
  68. data/lib/ri_cal/property_value/cal_address.rb +11 -0
  69. data/lib/ri_cal/property_value/date.rb +180 -0
  70. data/lib/ri_cal/property_value/date_time.rb +351 -0
  71. data/lib/ri_cal/property_value/date_time/additive_methods.rb +44 -0
  72. data/lib/ri_cal/property_value/date_time/time_machine.rb +159 -0
  73. data/lib/ri_cal/property_value/date_time/timezone_support.rb +100 -0
  74. data/lib/ri_cal/property_value/duration.rb +110 -0
  75. data/lib/ri_cal/property_value/geo.rb +11 -0
  76. data/lib/ri_cal/property_value/integer.rb +12 -0
  77. data/lib/ri_cal/property_value/occurrence_list.rb +144 -0
  78. data/lib/ri_cal/property_value/period.rb +86 -0
  79. data/lib/ri_cal/property_value/recurrence_rule.rb +154 -0
  80. data/lib/ri_cal/property_value/recurrence_rule/enumeration_support_methods.rb +100 -0
  81. data/lib/ri_cal/property_value/recurrence_rule/enumerator.rb +79 -0
  82. data/lib/ri_cal/property_value/recurrence_rule/initialization_methods.rb +148 -0
  83. data/lib/ri_cal/property_value/recurrence_rule/negative_setpos_enumerator.rb +53 -0
  84. data/lib/ri_cal/property_value/recurrence_rule/numbered_span.rb +31 -0
  85. data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer.rb +135 -0
  86. data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_day_incrementer.rb +86 -0
  87. data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_hour_incrementer.rb +31 -0
  88. data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_minute_incrementer.rb +32 -0
  89. data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_month_incrementer.rb +52 -0
  90. data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_monthday_incrementer.rb +31 -0
  91. data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_numbered_day_incrementer.rb +38 -0
  92. data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_second_incrementer.rb +32 -0
  93. data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_weekno_incrementer.rb +69 -0
  94. data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_yearday_incrementer.rb +31 -0
  95. data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/daily_incrementer.rb +28 -0
  96. data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/frequency_incrementer.rb +80 -0
  97. data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/hourly_incrementer.rb +23 -0
  98. data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/list_incrementer.rb +106 -0
  99. data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/minutely_incrementer.rb +23 -0
  100. data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/monthly_incrementer.rb +33 -0
  101. data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/null_sub_cycle_incrementer.rb +43 -0
  102. data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/secondly_incrementer.rb +28 -0
  103. data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/weekly_incrementer.rb +37 -0
  104. data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/yearly_incrementer.rb +57 -0
  105. data/lib/ri_cal/property_value/recurrence_rule/recurring_day.rb +131 -0
  106. data/lib/ri_cal/property_value/recurrence_rule/recurring_month_day.rb +64 -0
  107. data/lib/ri_cal/property_value/recurrence_rule/recurring_numbered_week.rb +33 -0
  108. data/lib/ri_cal/property_value/recurrence_rule/recurring_year_day.rb +53 -0
  109. data/lib/ri_cal/property_value/recurrence_rule/time_manipulation.rb +42 -0
  110. data/lib/ri_cal/property_value/recurrence_rule/validations.rb +125 -0
  111. data/lib/ri_cal/property_value/text.rb +40 -0
  112. data/lib/ri_cal/property_value/uri.rb +11 -0
  113. data/lib/ri_cal/property_value/utc_offset.rb +33 -0
  114. data/lib/ri_cal/required_timezones.rb +55 -0
  115. data/performance/empty_propval/subject.rb +43 -0
  116. data/performance/paris_eastern/subject.rb +90 -0
  117. data/performance/penultimate_weekday/subject.rb +15 -0
  118. data/performance/psm_big_enum/ical.ics +3171 -0
  119. data/performance/psm_big_enum/subject.rb +16 -0
  120. data/performance/utah_cycling/subject.rb +55 -0
  121. data/ri_cal.gemspec +48 -0
  122. data/script/benchmark_subject +23 -0
  123. data/script/console +10 -0
  124. data/script/destroy +14 -0
  125. data/script/generate +14 -0
  126. data/script/profile_subject +29 -0
  127. data/script/txt2html +71 -0
  128. data/spec/ri_cal/bugreports_spec.rb +249 -0
  129. data/spec/ri_cal/component/alarm_spec.rb +12 -0
  130. data/spec/ri_cal/component/calendar_spec.rb +88 -0
  131. data/spec/ri_cal/component/event_spec.rb +718 -0
  132. data/spec/ri_cal/component/freebusy_spec.rb +12 -0
  133. data/spec/ri_cal/component/journal_spec.rb +37 -0
  134. data/spec/ri_cal/component/t_z_info_timezone_spec.rb +59 -0
  135. data/spec/ri_cal/component/timezone_spec.rb +236 -0
  136. data/spec/ri_cal/component/todo_spec.rb +112 -0
  137. data/spec/ri_cal/component_spec.rb +224 -0
  138. data/spec/ri_cal/core_extensions/string/conversions_spec.rb +78 -0
  139. data/spec/ri_cal/core_extensions/time/calculations_spec.rb +188 -0
  140. data/spec/ri_cal/core_extensions/time/week_day_predicates_spec.rb +45 -0
  141. data/spec/ri_cal/fast_date_time_spec.rb +67 -0
  142. data/spec/ri_cal/occurrence_enumerator_spec.rb +611 -0
  143. data/spec/ri_cal/parser_spec.rb +337 -0
  144. data/spec/ri_cal/property_value/date_spec.rb +53 -0
  145. data/spec/ri_cal/property_value/date_time_spec.rb +383 -0
  146. data/spec/ri_cal/property_value/duration_spec.rb +126 -0
  147. data/spec/ri_cal/property_value/occurrence_list_spec.rb +72 -0
  148. data/spec/ri_cal/property_value/period_spec.rb +63 -0
  149. data/spec/ri_cal/property_value/recurrence_rule/recurring_year_day_spec.rb +21 -0
  150. data/spec/ri_cal/property_value/recurrence_rule_spec.rb +1814 -0
  151. data/spec/ri_cal/property_value/text_spec.rb +25 -0
  152. data/spec/ri_cal/property_value/utc_offset_spec.rb +48 -0
  153. data/spec/ri_cal/property_value_spec.rb +125 -0
  154. data/spec/ri_cal/required_timezones_spec.rb +67 -0
  155. data/spec/ri_cal_spec.rb +53 -0
  156. data/spec/spec.opts +4 -0
  157. data/spec/spec_helper.rb +50 -0
  158. data/tasks/gem_loader/load_active_support.rb +3 -0
  159. data/tasks/gem_loader/load_tzinfo_gem.rb +2 -0
  160. data/tasks/ri_cal.rake +412 -0
  161. data/tasks/spec.rake +102 -0
  162. metadata +260 -0
@@ -0,0 +1,42 @@
1
+ module RiCal
2
+ class PropertyValue
3
+ class RecurrenceRule < PropertyValue
4
+ #- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
5
+ #
6
+ module TimeManipulation #:nodoc:
7
+
8
+ def advance_day(date_time)
9
+ date_time.advance(:days => 1)
10
+ end
11
+
12
+ def first_hour_of_day(date_time)
13
+ date_time.change(:hour => 0)
14
+ end
15
+
16
+ def advance_week(date_time)
17
+ date_time.advance(:days => 7)
18
+ end
19
+
20
+ def first_day_of_week(wkst_day, date_time)
21
+ date_time.at_start_of_week_with_wkst(wkst_day)
22
+ end
23
+
24
+ def advance_month(date_time)
25
+ date_time.advance(:months => 1)
26
+ end
27
+
28
+ def first_day_of_month(date_time)
29
+ date_time.change(:day => 1)
30
+ end
31
+
32
+ def advance_year(date_time)
33
+ date_time.advance(:years => 1)
34
+ end
35
+
36
+ def first_day_of_year(date_time)
37
+ date_time.change(:month => 1, :day => 1)
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,125 @@
1
+ module RiCal
2
+ class PropertyValue
3
+ class RecurrenceRule < PropertyValue
4
+ #- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
5
+ #
6
+ module Validations #:nodoc:
7
+ # Validate that the parameters of the reciever conform to RFC 2445
8
+ # If errors are found they will be added to the receivers errors
9
+ #
10
+ # Whenever any of the parameters are set, e.g. with:
11
+ # recurrence_rule.count = 2
12
+ # the errors will be reset
13
+ def valid?
14
+ validate if @errors.nil?
15
+ errors.empty?
16
+ end
17
+
18
+ # Return any errors found during validation
19
+ # See #valid?
20
+ def errors
21
+ @errors ||= []
22
+ end
23
+
24
+ def reset_errors # :nodoc:
25
+ @errors = nil
26
+ end
27
+
28
+ # Used by #valid? to validate that the parameters of the reciever conform to RFC 2445
29
+ # If errors are found they will be added to the receivers errors
30
+ #
31
+ # Whenever any of the parameters are set, e.g. with:
32
+ # recurrence_rule.count = 2
33
+ # the errors will be reset
34
+ def validate
35
+ @errors = []
36
+ validate_termination
37
+ validate_freq
38
+ validate_interval
39
+ validate_int_by_list(:bysecond, (0..59))
40
+ validate_int_by_list(:byminute, (0..59))
41
+ validate_int_by_list(:byhour, (0..23))
42
+ validate_int_by_list(:bymonth, (1..12))
43
+ validate_bysetpos
44
+ validate_byday_list
45
+ validate_bymonthday_list
46
+ validate_byyearday_list
47
+ validate_byweekno_list
48
+ validate_wkst
49
+ end
50
+
51
+ def validate_termination
52
+ errors << "COUNT and UNTIL cannot both be specified" if @count && @until
53
+ end
54
+
55
+ def validate_freq
56
+ if @freq
57
+ unless %w{
58
+ SECONDLY MINUTELY HOURLY DAILY
59
+ WEEKLY MONTHLY YEARLY
60
+ }.include?(@freq.upcase)
61
+ errors << "Invalid frequency '#{@freq}'"
62
+ end
63
+ else
64
+ errors << "RecurrenceRule must have a value for FREQ"
65
+ end
66
+ end
67
+
68
+ def validate_interval
69
+ if @interval
70
+ errors << "interval must be a positive integer" unless @interval > 0
71
+ end
72
+ end
73
+
74
+ def validate_wkst
75
+ errors << "#{wkst.inspect} is invalid for wkst" unless %w{MO TU WE TH FR SA SU}.include?(wkst)
76
+ end
77
+
78
+ def validate_int_by_list(which, test)
79
+ vals = by_list[which] || []
80
+ vals.each do |val|
81
+ errors << "#{val} is invalid for #{which}" unless test === val
82
+ end
83
+ end
84
+
85
+ def validate_bysetpos
86
+ vals = by_list[:bysetpos] || []
87
+ vals.each do |val|
88
+ errors << "#{val} is invalid for bysetpos" unless (-366..-1) === val || (1..366) === val
89
+ end
90
+ unless vals.empty?
91
+ errors << "bysetpos cannot be used without another by_xxx rule part" unless by_list.length > 1
92
+ end
93
+ end
94
+
95
+ def validate_byday_list
96
+ days = by_list[:byday] || []
97
+ days.each do |day|
98
+ errors << "#{day.source.inspect} is not a valid day" unless day.valid?
99
+ end
100
+ end
101
+
102
+ def validate_bymonthday_list
103
+ days = by_list[:bymonthday] || []
104
+ days.each do |day|
105
+ errors << "#{day.source.inspect} is not a valid month day" unless day.valid?
106
+ end
107
+ end
108
+
109
+ def validate_byyearday_list
110
+ days = by_list[:byyearday] || []
111
+ days.each do |day|
112
+ errors << "#{day.source.inspect} is not a valid year day" unless day.valid?
113
+ end
114
+ end
115
+
116
+ def validate_byweekno_list
117
+ days = by_list[:byweekno] || []
118
+ days.each do |day|
119
+ errors << "#{day.source.inspect} is not a valid week number" unless day.valid?
120
+ end
121
+ end
122
+ end
123
+ end
124
+ end
125
+ end
@@ -0,0 +1,40 @@
1
+ module RiCal
2
+ class PropertyValue
3
+ #- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
4
+ #
5
+ # RiCal::PropertyValue::Text represents an icalendar Text property value
6
+ # which is defined in
7
+ # rfc 2445 section 4.3.11 pp 45-46
8
+ class Text < PropertyValue
9
+
10
+ # Return the string value of the receiver
11
+ def ruby_value
12
+ if value
13
+ value.gsub(/\\[;,nN\\]/) {|match|
14
+ case match[1,1]
15
+ when /[,;\\]/
16
+ match[1,1]
17
+ when 'n', 'N'
18
+ "\n"
19
+ else
20
+ match
21
+ end
22
+ }
23
+ else
24
+ nil
25
+ end
26
+ end
27
+
28
+ def self.convert(parent, string) #:nodoc:
29
+ ical_str = string.gsub(/\n\r?|\r\n?|,|;|\\/) {|match|
30
+ if ["\n", "\r", "\n\r", "\r\n"].include?(match)
31
+ '\\n'
32
+ else
33
+ "\\#{match}"
34
+ end
35
+ }
36
+ self.new(parent, :value => ical_str)
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,11 @@
1
+ module RiCal
2
+ class PropertyValue
3
+ #- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
4
+ #
5
+ # RiCal::PropertyValue::Uri represents an icalendar Uri property value
6
+ # which is defined in
7
+ # rfc 2445 section 4.8.4.6 p 110
8
+ class Uri < PropertyValue
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,33 @@
1
+ module RiCal
2
+ class PropertyValue
3
+ #- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
4
+ #
5
+ class UtcOffset < PropertyValue # :nodoc:
6
+ attr_accessor :sign, :hours, :minutes, :seconds
7
+
8
+ def value=(string)
9
+ @value = string
10
+ parse_match = /([+-])(\d\d)(\d\d)(\d\d)?/.match(string)
11
+ if parse_match
12
+ @sign = parse_match[1] == "+" ? 1 : -1
13
+ @hours = parse_match[2].to_i
14
+ @minutes = parse_match[3].to_i
15
+ @seconds = parse_match[4].to_i || 0
16
+ end
17
+ end
18
+
19
+ def to_seconds
20
+ @sign * ((((hours*60) + minutes) * 60) + seconds)
21
+ end
22
+
23
+ def add_to_date_time_value(date_time_value)
24
+ date_time_value.advance(:hours => sign * hours, :minutes => sign * minutes, :seconds => sign * minutes)
25
+ end
26
+
27
+ def subtract_from_date_time_value(date_time_value)
28
+ signum = -1 * sign
29
+ date_time_value.advance(:hours => signum * hours, :minutes => signum * minutes, :seconds => signum * minutes)
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,55 @@
1
+ module RiCal
2
+ #- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
3
+ #
4
+ # RequireTimezones collects the timezones used by a given calendar component or set of calendar components
5
+ # For each timezone we collect it's id, and the earliest and latest times which reference the zone
6
+ class RequiredTimezones #:nodoc:
7
+
8
+
9
+ # A required timezone represents a single timezone and the earliest and latest times which reference it.
10
+ class RequiredTimezone #:nodoc:
11
+
12
+ attr_reader :first_time, :last_time, :timezone
13
+
14
+ def initialize(tzid)
15
+ @timezone = RiCal::Component::TZInfoTimezone.new(TZInfo::Timezone.get(tzid))
16
+ end
17
+
18
+ def tzid
19
+ @timezone.identifier
20
+ end
21
+
22
+ def add_datetime(date_time)
23
+ if @first_time
24
+ @first_time = date_time if date_time < @first_time
25
+ else
26
+ @first_time = date_time
27
+ end
28
+ if @last_time
29
+ @last_time = date_time if date_time > @last_time
30
+ else
31
+ @last_time = date_time
32
+ end
33
+ end
34
+ end
35
+
36
+ def required_timezones
37
+ @required_zones ||= {}
38
+ end
39
+
40
+ def required_zones
41
+ required_timezones.values
42
+ end
43
+
44
+ def export_to(export_stream)
45
+ required_zones.each do |z|
46
+ tzinfo_timezone =z.timezone
47
+ tzinfo_timezone.export_local_to(export_stream, z.first_time, z.last_time)
48
+ end
49
+ end
50
+
51
+ def add_datetime(date_time, tzid)
52
+ (required_timezones[tzid] ||= RequiredTimezone.new(tzid)).add_datetime(date_time)
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,43 @@
1
+ class Subject
2
+ def initialize(out=STDOUT)
3
+ cals = RiCal.parse_string <<-END_OF_DATA
4
+ BEGIN:VCALENDAR
5
+ METHOD:REQUEST
6
+ PRODID:Microsoft CDO for Microsoft Exchange
7
+ VERSION:2.0
8
+ BEGIN:VTIMEZONE
9
+ TZID:(GMT-05.00) Eastern Time (US & Canada)
10
+ X-MICROSOFT-CDO-TZID:10
11
+ BEGIN:STANDARD
12
+ DTSTART:16010101T020000
13
+ TZOFFSETFROM:-0400
14
+ TZOFFSETTO:-0500
15
+ RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=11;BYDAY=1SU
16
+ END:STANDARD
17
+ BEGIN:DAYLIGHT
18
+ DTSTART:16010101T020000
19
+ TZOFFSETFROM:-0500
20
+ TZOFFSETTO:-0400
21
+ RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=3;BYDAY=2SU
22
+ END:DAYLIGHT
23
+ END:VTIMEZONE
24
+ BEGIN:VEVENT
25
+ DTSTAMP:20090724T143205Z
26
+ DTSTART;TZID="(GMT-05.00) Eastern Time (US & Canada)":20090804T120000
27
+ SUMMARY:FW: ALL HANDS MEETING
28
+ DTEND;TZID="(GMT-05.00) Eastern Time (US & Canada)":20090804T133000
29
+ DESCRIPTION:Some event
30
+ END:VEVENT
31
+ END:VCALENDAR
32
+ END_OF_DATA
33
+
34
+ cal = cals.first
35
+ @event = cal.events.first
36
+ end
37
+
38
+ def run
39
+ puts "start"
40
+ @event.dtstart
41
+ puts "done"
42
+ end
43
+ end
@@ -0,0 +1,90 @@
1
+ class Subject
2
+ def initialize(out=STDOUT)
3
+ cals = RiCal.parse_string <<-END_OF_DATA
4
+ BEGIN:VCALENDAR
5
+ METHOD:PUBLISH
6
+ X-WR-TIMEZONE:America/New_York
7
+ PRODID:-//Apple Inc.//iCal 3.0//EN
8
+ CALSCALE:GREGORIAN
9
+ X-WR-CALNAME:Test
10
+ VERSION:2.0
11
+ X-WR-RELCALID:58DB0663-196B-4B6B-A05A-A53049661280
12
+ X-APPLE-CALENDAR-COLOR:#0252D4
13
+ BEGIN:VTIMEZONE
14
+ TZID:Europe/Paris
15
+ BEGIN:DAYLIGHT
16
+ TZOFFSETFROM:+0100
17
+ TZOFFSETTO:+0200
18
+ DTSTART:19810329T020000
19
+ RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
20
+ TZNAME:CEST
21
+ END:DAYLIGHT
22
+ BEGIN:STANDARD
23
+ TZOFFSETFROM:+0200
24
+ TZOFFSETTO:+0100
25
+ DTSTART:19961027T030000
26
+ RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
27
+ TZNAME:CET
28
+ END:STANDARD
29
+ END:VTIMEZONE
30
+ BEGIN:VTIMEZONE
31
+ TZID:US/Eastern
32
+ BEGIN:DAYLIGHT
33
+ TZOFFSETFROM:-0500
34
+ TZOFFSETTO:-0400
35
+ DTSTART:20070311T020000
36
+ RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
37
+ TZNAME:EDT
38
+ END:DAYLIGHT
39
+ BEGIN:STANDARD
40
+ TZOFFSETFROM:-0400
41
+ TZOFFSETTO:-0500
42
+ DTSTART:20071104T020000
43
+ RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
44
+ TZNAME:EST
45
+ END:STANDARD
46
+ END:VTIMEZONE
47
+ BEGIN:VEVENT
48
+ SEQUENCE:3
49
+ TRANSP:OPAQUE
50
+ UID:AC2EFB19-A8A8-49EF-929F-CA0975374ED6
51
+ DTSTART:20090501T000000Z
52
+ DTSTAMP:20090501T174405Z
53
+ SUMMARY:UTC Event
54
+ CREATED:20090501T174347Z
55
+ DTEND:20090501T010000Z
56
+ END:VEVENT
57
+ BEGIN:VEVENT
58
+ SEQUENCE:2
59
+ TRANSP:OPAQUE
60
+ UID:A5517A09-C53E-4E1F-A642-EA47680BF2B6
61
+ DTSTART;TZID=US/Eastern:20090430T140000
62
+ DTSTAMP:20090501T174428Z
63
+ SUMMARY:Eastern Event
64
+ CREATED:20090501T174415Z
65
+ DTEND;TZID=US/Eastern:20090430T150000
66
+ END:VEVENT
67
+ BEGIN:VEVENT
68
+ SEQUENCE:3
69
+ TRANSP:OPAQUE
70
+ UID:B5024763-9197-4A60-A96E-D8D59D578BB2
71
+ DTSTART;TZID=Europe/Paris:20090430T140000
72
+ DTSTAMP:20090501T174509Z
73
+ SUMMARY:Paris Event
74
+ CREATED:20090501T174439Z
75
+ DTEND;TZID=Europe/Paris:20090430T150000
76
+ END:VEVENT
77
+ END:VCALENDAR
78
+ END_OF_DATA
79
+
80
+ cal = cals.first
81
+ event = cal.events.find {|event| event.summary == "Paris Event"}
82
+ @date_time = event.dtstart_property
83
+ end
84
+
85
+ def run
86
+ puts "start"
87
+ @date_time.in_time_zone("US/Eastern")
88
+ puts "done"
89
+ end
90
+ end