rubyredrick-ri_cal 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +19 -2
- data/Manifest.txt +6 -3
- data/README.txt +130 -44
- data/Rakefile +1 -1
- data/copyrights.txt +1 -2
- data/lib/ri_cal/component/alarm.rb +1 -2
- data/lib/ri_cal/component/calendar.rb +25 -9
- data/lib/ri_cal/component/event.rb +1 -2
- data/lib/ri_cal/component/freebusy.rb +1 -2
- data/lib/ri_cal/component/journal.rb +1 -2
- data/lib/ri_cal/component/t_z_info_timezone.rb +1 -2
- data/lib/ri_cal/component/timezone/daylight_period.rb +1 -2
- data/lib/ri_cal/component/timezone/standard_period.rb +1 -2
- data/lib/ri_cal/component/timezone/timezone_period.rb +1 -2
- data/lib/ri_cal/component/timezone.rb +5 -2
- data/lib/ri_cal/component.rb +22 -7
- data/lib/ri_cal/core_extensions/date/conversions.rb +8 -7
- data/lib/ri_cal/core_extensions/date_time.rb +4 -2
- data/lib/ri_cal/core_extensions/object/conversions.rb +1 -1
- data/lib/ri_cal/core_extensions/string/conversions.rb +37 -6
- data/lib/ri_cal/core_extensions/time/conversions.rb +11 -7
- data/lib/ri_cal/core_extensions/time/tzid_access.rb +37 -0
- data/lib/ri_cal/core_extensions/time.rb +3 -1
- data/lib/ri_cal/floating_timezone.rb +32 -0
- data/lib/ri_cal/invalid_property_value.rb +8 -0
- data/lib/ri_cal/invalid_timezone_identifer.rb +2 -2
- data/lib/ri_cal/occurrence_enumerator.rb +5 -3
- data/lib/ri_cal/parser.rb +8 -8
- data/lib/ri_cal/properties/alarm.rb +8 -8
- data/lib/ri_cal/properties/event.rb +60 -60
- data/lib/ri_cal/properties/freebusy.rb +16 -16
- data/lib/ri_cal/properties/journal.rb +58 -58
- data/lib/ri_cal/properties/timezone_period.rb +23 -23
- data/lib/ri_cal/properties/todo.rb +63 -64
- data/lib/ri_cal/property_value/array.rb +10 -2
- data/lib/ri_cal/property_value/cal_address.rb +1 -2
- data/lib/ri_cal/property_value/date.rb +15 -3
- data/lib/ri_cal/property_value/date_time/additive_methods.rb +34 -33
- data/lib/ri_cal/property_value/date_time/time_machine.rb +175 -174
- data/lib/ri_cal/property_value/date_time/timezone_support.rb +70 -52
- data/lib/ri_cal/property_value/date_time.rb +47 -77
- data/lib/ri_cal/property_value/duration.rb +6 -3
- data/lib/ri_cal/property_value/geo.rb +1 -2
- data/lib/ri_cal/property_value/integer.rb +1 -2
- data/lib/ri_cal/property_value/occurrence_list.rb +79 -26
- data/lib/ri_cal/property_value/period.rb +23 -3
- data/lib/ri_cal/property_value/recurrence_rule/enumeration_support_methods.rb +1 -2
- data/lib/ri_cal/property_value/recurrence_rule/enumerator.rb +1 -2
- data/lib/ri_cal/property_value/recurrence_rule/initialization_methods.rb +1 -2
- data/lib/ri_cal/property_value/recurrence_rule/negative_setpos_enumerator.rb +1 -2
- data/lib/ri_cal/property_value/recurrence_rule/numbered_span.rb +1 -2
- data/lib/ri_cal/property_value/recurrence_rule/occurence_incrementer.rb +1 -2
- data/lib/ri_cal/property_value/recurrence_rule/recurring_day.rb +1 -2
- data/lib/ri_cal/property_value/recurrence_rule/recurring_month_day.rb +1 -2
- data/lib/ri_cal/property_value/recurrence_rule/recurring_numbered_week.rb +1 -2
- data/lib/ri_cal/property_value/recurrence_rule/recurring_year_day.rb +1 -2
- data/lib/ri_cal/property_value/recurrence_rule/validations.rb +1 -2
- data/lib/ri_cal/property_value/recurrence_rule.rb +3 -4
- data/lib/ri_cal/property_value/text.rb +1 -2
- data/lib/ri_cal/property_value/uri.rb +1 -2
- data/lib/ri_cal/property_value/utc_offset.rb +1 -2
- data/lib/ri_cal/property_value.rb +42 -11
- data/lib/ri_cal/required_timezones.rb +1 -2
- data/lib/ri_cal.rb +1 -2
- data/ri_cal.gemspec +6 -4
- data/spec/ri_cal/component/alarm_spec.rb +1 -2
- data/spec/ri_cal/component/calendar_spec.rb +1 -2
- data/spec/ri_cal/component/event_spec.rb +168 -13
- data/spec/ri_cal/component/freebusy_spec.rb +1 -2
- data/spec/ri_cal/component/journal_spec.rb +1 -2
- data/spec/ri_cal/component/t_z_info_timezone_spec.rb +1 -2
- data/spec/ri_cal/component/timezone_spec.rb +1 -2
- data/spec/ri_cal/component/todo_spec.rb +4 -5
- data/spec/ri_cal/component_spec.rb +30 -18
- data/spec/ri_cal/core_extensions/string/conversions_spec.rb +78 -0
- data/spec/ri_cal/core_extensions/time/calculations_spec.rb +1 -2
- data/spec/ri_cal/core_extensions/time/week_day_predicates_spec.rb +1 -2
- data/spec/ri_cal/occurrence_enumerator_spec.rb +23 -2
- data/spec/ri_cal/parser_spec.rb +6 -7
- data/spec/ri_cal/property_value/date_spec.rb +1 -2
- data/spec/ri_cal/property_value/date_time_spec.rb +54 -119
- data/spec/ri_cal/property_value/duration_spec.rb +12 -2
- data/spec/ri_cal/property_value/occurrence_list_spec.rb +67 -0
- data/spec/ri_cal/property_value/period_spec.rb +1 -2
- data/spec/ri_cal/property_value/recurrence_rule/recurring_year_day_spec.rb +1 -2
- data/spec/ri_cal/property_value/recurrence_rule_spec.rb +1 -2
- data/spec/ri_cal/property_value/text_spec.rb +1 -2
- data/spec/ri_cal/property_value/utc_offset_spec.rb +1 -2
- data/spec/ri_cal/property_value_spec.rb +19 -8
- data/spec/ri_cal/required_timezones_spec.rb +1 -2
- data/spec/ri_cal_spec.rb +1 -2
- data/spec/spec_helper.rb +2 -7
- data/tasks/ri_cal.rake +20 -13
- data/tasks/spec.rake +1 -1
- metadata +8 -5
- data/lib/ri_cal/core_extensions/date_time/conversions.rb +0 -27
- data/lib/ri_cal/time_with_floating_timezone.rb +0 -59
data/History.txt
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
=== 0.0.3
|
|
2
|
+
* Added tzid method to Ruby Time and DateTime instances, and to ActiveRecord::TimeWithZone if it is defined this method is used to determine the desired
|
|
3
|
+
timezone when an instance of one of these classes is given as the value of a datetime property. If the tzid is nil then the default tzid is used,
|
|
4
|
+
if it is set to :floating then the property will be a floating time.
|
|
5
|
+
* Removed the ability to pass an array with a tzid string and a date-time since the above made it unnecessary
|
|
6
|
+
* The ruby datetime property returned from the ruby_value method on the DateTime property will return an instance of ::DateTime with:
|
|
7
|
+
** The proper utc offset
|
|
8
|
+
** The tzid set to the right tzid
|
|
9
|
+
* Made exdate/rdate building possible
|
|
10
|
+
* Added a default_tzid attribute to the Calendar component, if this attribute is not set for a particular calendar it will delegate to the default set
|
|
11
|
+
for the DateTime property class.
|
|
12
|
+
* Added fix patches from
|
|
13
|
+
** http://github.com/kjwierenga/ri_cal
|
|
14
|
+
** http://github.com/wesmaldonado/ri_cal
|
|
2
15
|
|
|
3
|
-
|
|
16
|
+
=== 0.0.2
|
|
17
|
+
* Fixed gemspec
|
|
18
|
+
== 0.0.1
|
|
19
|
+
|
|
20
|
+
* Initial public release
|
data/Manifest.txt
CHANGED
|
@@ -36,7 +36,6 @@ lib/ri_cal/core_extensions/array/conversions.rb
|
|
|
36
36
|
lib/ri_cal/core_extensions/date.rb
|
|
37
37
|
lib/ri_cal/core_extensions/date/conversions.rb
|
|
38
38
|
lib/ri_cal/core_extensions/date_time.rb
|
|
39
|
-
lib/ri_cal/core_extensions/date_time/conversions.rb
|
|
40
39
|
lib/ri_cal/core_extensions/object.rb
|
|
41
40
|
lib/ri_cal/core_extensions/object/conversions.rb
|
|
42
41
|
lib/ri_cal/core_extensions/string.rb
|
|
@@ -44,7 +43,10 @@ lib/ri_cal/core_extensions/string/conversions.rb
|
|
|
44
43
|
lib/ri_cal/core_extensions/time.rb
|
|
45
44
|
lib/ri_cal/core_extensions/time/calculations.rb
|
|
46
45
|
lib/ri_cal/core_extensions/time/conversions.rb
|
|
46
|
+
lib/ri_cal/core_extensions/time/tzid_access.rb
|
|
47
47
|
lib/ri_cal/core_extensions/time/week_day_predicates.rb
|
|
48
|
+
lib/ri_cal/floating_timezone.rb
|
|
49
|
+
lib/ri_cal/invalid_property_value.rb
|
|
48
50
|
lib/ri_cal/invalid_timezone_identifer.rb
|
|
49
51
|
lib/ri_cal/occurrence_enumerator.rb
|
|
50
52
|
lib/ri_cal/parser.rb
|
|
@@ -85,7 +87,6 @@ lib/ri_cal/property_value/text.rb
|
|
|
85
87
|
lib/ri_cal/property_value/uri.rb
|
|
86
88
|
lib/ri_cal/property_value/utc_offset.rb
|
|
87
89
|
lib/ri_cal/required_timezones.rb
|
|
88
|
-
lib/ri_cal/time_with_floating_timezone.rb
|
|
89
90
|
ri_cal.gemspec
|
|
90
91
|
sample_ical_files/from_ical_dot_app/test1.ics
|
|
91
92
|
script/console
|
|
@@ -101,6 +102,7 @@ spec/ri_cal/component/t_z_info_timezone_spec.rb
|
|
|
101
102
|
spec/ri_cal/component/timezone_spec.rb
|
|
102
103
|
spec/ri_cal/component/todo_spec.rb
|
|
103
104
|
spec/ri_cal/component_spec.rb
|
|
105
|
+
spec/ri_cal/core_extensions/string/conversions_spec.rb
|
|
104
106
|
spec/ri_cal/core_extensions/time/calculations_spec.rb
|
|
105
107
|
spec/ri_cal/core_extensions/time/week_day_predicates_spec.rb
|
|
106
108
|
spec/ri_cal/occurrence_enumerator_spec.rb
|
|
@@ -108,6 +110,7 @@ spec/ri_cal/parser_spec.rb
|
|
|
108
110
|
spec/ri_cal/property_value/date_spec.rb
|
|
109
111
|
spec/ri_cal/property_value/date_time_spec.rb
|
|
110
112
|
spec/ri_cal/property_value/duration_spec.rb
|
|
113
|
+
spec/ri_cal/property_value/occurrence_list_spec.rb
|
|
111
114
|
spec/ri_cal/property_value/period_spec.rb
|
|
112
115
|
spec/ri_cal/property_value/recurrence_rule/recurring_year_day_spec.rb
|
|
113
116
|
spec/ri_cal/property_value/recurrence_rule_spec.rb
|
|
@@ -119,4 +122,4 @@ spec/ri_cal_spec.rb
|
|
|
119
122
|
spec/spec.opts
|
|
120
123
|
spec/spec_helper.rb
|
|
121
124
|
tasks/ri_cal.rake
|
|
122
|
-
tasks/spec.rake
|
|
125
|
+
tasks/spec.rake
|
data/README.txt
CHANGED
|
@@ -14,6 +14,8 @@ but do not support important things like enumerating occurrences of repeating ev
|
|
|
14
14
|
|
|
15
15
|
This is a clean-slate implementation of RFC2445.
|
|
16
16
|
|
|
17
|
+
A Google group for discussion of this library has been set up http://groups.google.com/group/rical_gem
|
|
18
|
+
|
|
17
19
|
== FEATURES/PROBLEMS:
|
|
18
20
|
|
|
19
21
|
* All examples of recurring events in RFC 2445 are handled. RSpec examples are provided for them.
|
|
@@ -22,17 +24,18 @@ This is a clean-slate implementation of RFC2445.
|
|
|
22
24
|
|
|
23
25
|
=== Components and properties
|
|
24
26
|
|
|
25
|
-
An iCalendar calendar comprises subcomponents like Events, Timezones and Todos.
|
|
26
|
-
properties, for example an event has a dtstart property which defines the time (and date) on
|
|
27
|
-
starts.
|
|
27
|
+
An iCalendar calendar comprises subcomponents like Events, Timezones and Todos. Each component may
|
|
28
|
+
have properties, for example an event has a dtstart property which defines the time (and date) on
|
|
29
|
+
which the event starts.
|
|
28
30
|
|
|
29
|
-
RiCal components will provide reasonable ruby objects as the values of these properties, and allow
|
|
30
|
-
to be set to ruby objects which are reasonable for the particular property.
|
|
31
|
-
can be set to a ruby Time, DateTime or Date object, and will
|
|
31
|
+
RiCal components will provide reasonable ruby objects as the values of these properties, and allow
|
|
32
|
+
the properties to be set to ruby objects which are reasonable for the particular property. For
|
|
33
|
+
example time properties like dtstart can be set to a ruby Time, DateTime or Date object, and will
|
|
34
|
+
return a DateTime or Date object when queried.
|
|
32
35
|
|
|
33
|
-
The methods for accessing the properties of each type of component are defined in a module with the
|
|
34
|
-
as the component class in the RiCal::properties module.
|
|
35
|
-
RiCal::Component::Event are defined in RiCal::Properties::Event
|
|
36
|
+
The methods for accessing the properties of each type of component are defined in a module with the
|
|
37
|
+
same name as the component class in the RiCal::properties module. For example the property
|
|
38
|
+
accessing methods for RiCal::Component::Event are defined in RiCal::Properties::Event
|
|
36
39
|
|
|
37
40
|
=== Creating Calendars and Calendar Components
|
|
38
41
|
|
|
@@ -51,12 +54,14 @@ RiCal provides a builder DSL for creating calendars and calendar components. An
|
|
|
51
54
|
end
|
|
52
55
|
end
|
|
53
56
|
|
|
54
|
-
This style is for compatibility with the iCalendar and vpim to ease migration.
|
|
55
|
-
in the context of a different object which cause
|
|
56
|
-
implicit references to self.
|
|
57
|
-
|
|
57
|
+
This style is for compatibility with the iCalendar and vpim to ease migration. The downside is that
|
|
58
|
+
the block is evaluated in the context of a different object which can cause surprises if the block
|
|
59
|
+
contains direct instance variable references or implicit references to self. Note that, in this
|
|
60
|
+
style, one must use 'declarative' method calls like dtstart to set values rather than more natural
|
|
61
|
+
attribute writer methods, like dtstart=
|
|
58
62
|
|
|
59
|
-
Alternatively you can pass a block with a single argument, in this case the component being built
|
|
63
|
+
Alternatively you can pass a block with a single argument, in this case the component being built
|
|
64
|
+
will be passed as that argument
|
|
60
65
|
|
|
61
66
|
RiCal.Calendar do |cal|
|
|
62
67
|
cal.event do |event|
|
|
@@ -71,64 +76,145 @@ Alternatively you can pass a block with a single argument, in this case the comp
|
|
|
71
76
|
end
|
|
72
77
|
end
|
|
73
78
|
|
|
74
|
-
As the example shows, the two styles can be mixed, the inner block which builds the alarm uses the
|
|
79
|
+
As the example shows, the two styles can be mixed, the inner block which builds the alarm uses the
|
|
80
|
+
first style.
|
|
75
81
|
|
|
76
|
-
The blocks are evaluated in the context of an object which builds the calendar or calendar
|
|
77
|
-
starting with add_ or remove_ are sent to the component, method names which
|
|
78
|
-
the object being built will cause that setter to be sent
|
|
82
|
+
The blocks are evaluated in the context of an object which builds the calendar or calendar
|
|
83
|
+
component. method names starting with add_ or remove_ are sent to the component, method names which
|
|
84
|
+
correspond to a property value setter of the object being built will cause that setter to be sent
|
|
85
|
+
to the component with the provided value.
|
|
86
|
+
|
|
87
|
+
A method corresponding to the name of one of the components sub component will create the sub
|
|
88
|
+
component and evaluate a block if given in the context of the new subcomponent.
|
|
89
|
+
|
|
90
|
+
==== Multiply occurring properties
|
|
79
91
|
|
|
80
|
-
|
|
81
|
-
|
|
92
|
+
Certain RFC Components have properties which may be specified multiple times, for example, an Event
|
|
93
|
+
may have zero or more comment properties, A component will have a family of methods for
|
|
94
|
+
building/manipulating such a property, e.g.
|
|
82
95
|
|
|
83
|
-
|
|
96
|
+
Event#comment:: will return an array of comment strings.
|
|
97
|
+
Event#comment=:: takes a single comment string and gives the event a single comment property,
|
|
98
|
+
replacing any existing comment property collection.
|
|
99
|
+
Event#comments=:: takes multiple comment string arguments and gives the event a comment property for each,
|
|
100
|
+
replacing any existing comment property collection.
|
|
101
|
+
Event#add_comment:: takes a single comment string argument and adds a comment property.
|
|
102
|
+
Event#add_comments:: takes multiple comment string arguments and adds a comment property for each.
|
|
103
|
+
Event#remove_comment:: takes a single comment string argument and removes an existing comment property with that value.
|
|
104
|
+
Event#remove_comments:: takes multiple comment string argument and removes an existing comment property with that value.
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
==== Times, Time zones, and Floating Times
|
|
84
108
|
|
|
85
109
|
RFC2445 describes three different kinds of DATE-TIME values with respect to time zones:
|
|
86
110
|
|
|
87
|
-
1. date-times with a local time. These have no actual time zone, instead they are to be
|
|
111
|
+
1. date-times with a local time. These have no actual time zone, instead they are to be
|
|
112
|
+
interpreted in the local time zone of the viewer. These floating times are used for things
|
|
113
|
+
like the New Years celebration which is observed at local midnight whether you happen to be
|
|
114
|
+
in Paris, London, or New York.
|
|
88
115
|
|
|
89
|
-
2. date-times with UTC time. An application would either display these with an indication of
|
|
116
|
+
2. date-times with UTC time. An application would either display these with an indication of
|
|
117
|
+
the time zone, or convert them to the viewer's time zone, perhaps depending on user settings.
|
|
90
118
|
|
|
91
119
|
3. date-times with a specified time zone.
|
|
92
120
|
|
|
93
121
|
RiCal can be given ruby Time, DateTime, or Date objects for the value of properties requiring an
|
|
94
|
-
iCalendar DATE-TIME value.
|
|
95
|
-
|
|
122
|
+
iCalendar DATE-TIME value. It can also be given a string
|
|
123
|
+
|
|
124
|
+
Note that a date only DATE-TIME value has no time zone by definition, effectively such values float
|
|
125
|
+
and describe a date as viewed by the user in his/her local time zone.
|
|
96
126
|
|
|
97
|
-
|
|
98
|
-
|
|
127
|
+
When a Ruby Time or DateTime instance is used to set properties with with a DATE-TIME value, it
|
|
128
|
+
needs to determine which of the three types it represents. RiCal is designed to make use of the
|
|
129
|
+
TimeWithZone support which has been part of the ActiveSupport component of Ruby on Rails since
|
|
130
|
+
Rails 2.2. However it's been carefully designed not to require Rails or ActiveSupport, but to
|
|
131
|
+
dynamically detect the presence of the TimeWithZone support.
|
|
99
132
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
133
|
+
RiCal adds accessor methods for a tzid attribute to the Ruby Time, and DateTime classes as well as
|
|
134
|
+
a set_tzid method which sets the tzid attribute and returns the receiver for convenience in
|
|
135
|
+
building calendars. If ActiveSupport::TimeWithZone is defined, a tzid instance method is defined
|
|
136
|
+
which returns the identifier of the time zone.
|
|
104
137
|
|
|
105
138
|
When the value of a DATE-TIME property is set to a value, the following processing occurs:
|
|
106
139
|
|
|
107
|
-
* If the
|
|
140
|
+
* If the value is a string, then it must be a valid rfc 2445 date or datetime string optionally
|
|
141
|
+
preceded by a parameter specification e.g
|
|
142
|
+
|
|
143
|
+
"20010911" will be interpreted as a date
|
|
144
|
+
|
|
145
|
+
"20090530T123000Z" will be interpreted as the time May 30, 2009 at 12:30:00 UTC
|
|
146
|
+
|
|
147
|
+
"20090530T123000" will be interpreted as the time May 30, 2009 with a floating time zone
|
|
148
|
+
|
|
149
|
+
"TZID=America/New_York:20090530T123000" will be interpreted as the time May 30, 2009 in the time zone identified by "America/New_York"
|
|
150
|
+
|
|
151
|
+
* If the value is a Date it will be interpreted as that date
|
|
152
|
+
* If the value is a Time, DateTime, or TimeWithZone then the tzid attribute will determine the
|
|
153
|
+
time zone. If tzid returns nil then the default tzid will be used.
|
|
154
|
+
|
|
155
|
+
==== Default TZID
|
|
156
|
+
|
|
157
|
+
The PropertyValue::DateTime class has a default_tzid attribute which is initialized to "UTC".
|
|
108
158
|
|
|
109
|
-
|
|
159
|
+
The Component::Calendar class also has a default_tzid attribute, which may be set, but if it is not
|
|
160
|
+
set the default_tzid of the PropertyValue::DateTime class will be used.
|
|
110
161
|
|
|
111
|
-
|
|
112
|
-
|
|
162
|
+
To set the interpreting of Times and DateTimes which have no tzid as floating times, set the
|
|
163
|
+
default_tzid for Component::Calendar and/or PropertyValue::DateTime to :floating.
|
|
113
164
|
|
|
114
|
-
Also note that time zone identifiers are not standardized by RFC 2445. For an RiCal originated
|
|
115
|
-
time zone identifiers recognized by the TZInfo gem, or the TZInfo implementation provided
|
|
116
|
-
may be may be used.
|
|
117
|
-
are determined by the VTIMEZONE compoents within the
|
|
165
|
+
Also note that time zone identifiers are not standardized by RFC 2445. For an RiCal originated
|
|
166
|
+
calendar time zone identifiers recognized by the TZInfo gem, or the TZInfo implementation provided
|
|
167
|
+
by ActiveSupport as the case may be may be used. The valid time zone identifiers for a non-RiCal
|
|
168
|
+
generated calendar imported into RiCalendar are determined by the VTIMEZONE compoents within the
|
|
169
|
+
imported calendar.
|
|
118
170
|
|
|
119
|
-
If you use a timezone identifer within a calendar which is not defined within the calendar it will
|
|
120
|
-
you try to convert a timezone. In this case an InvalidTimezoneIdentifier error
|
|
171
|
+
If you use a timezone identifer within a calendar which is not defined within the calendar it will
|
|
172
|
+
detected at the time you try to convert a timezone. In this case an InvalidTimezoneIdentifier error
|
|
173
|
+
will be raised by the conversion method.
|
|
121
174
|
|
|
122
|
-
To explicitly set a floating time you can use the method #with_floating_timezone on Time or
|
|
175
|
+
To explicitly set a floating time you can use the method #with_floating_timezone on Time or
|
|
176
|
+
DateTime instances as in
|
|
123
177
|
|
|
124
178
|
event.dtstart = Time.parse("1/1/2010 00:00:00").with_floating_timezone
|
|
179
|
+
|
|
180
|
+
or the equivalent
|
|
181
|
+
|
|
182
|
+
event.dtstart = Time.parse("1/1/2010 00:00:00").set_tzid(:floating)
|
|
183
|
+
|
|
184
|
+
==== RDATE, and EXDATE properties (Occurrence Lists)
|
|
185
|
+
|
|
186
|
+
A calendar component which supports recurrence properties (e.g. Event) may have zero or more RDATE
|
|
187
|
+
and or EXDATE properties. Each RDATE/EXDATE property in turn specifies one or more occurrences to
|
|
188
|
+
be either added to or removed from the component's recurrence list. Each element of the list may be
|
|
189
|
+
either a DATE, a DATETIME, or a PERIOD, or the RFC 2445 string representation of one of these:
|
|
190
|
+
|
|
191
|
+
event.rdate = "20090305"
|
|
192
|
+
event.rdate = "20090305T120000"
|
|
193
|
+
event.rdate = "20090305T120000/P1H30M"
|
|
194
|
+
|
|
195
|
+
It can also have multiple occurrences, specified as multiple parameters:
|
|
196
|
+
|
|
197
|
+
event.rdate = "20090305T120000", "20090405T120000"
|
|
198
|
+
event.rdate = DateTime.parse("12 December, 2005 3:00 pm"), DateTime.civil(2001, 3, 4, 15, 30, 0)
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
Multiple string values can be combined separated by commas:
|
|
202
|
+
|
|
203
|
+
event.rdate = "20090305T120000,20090405T120000"
|
|
204
|
+
|
|
125
205
|
|
|
206
|
+
An occurrence list has one set of parameters, so only one timezone can be used, the timezone may
|
|
207
|
+
be set explicitly via the first argument. If the first argument is a string, it is first split on
|
|
208
|
+
commas. Then if the first segment (up to the first comma if any) is not a valid RFC 2445
|
|
209
|
+
representation of a DATE, DATETIME, or PERIOD, then it will be used as the timezone for the
|
|
210
|
+
occurrence list. Otherwise the arguments must have the same time zone or an InvalidPropertyValue
|
|
211
|
+
error will be raised.
|
|
126
212
|
=== Parsing
|
|
127
213
|
|
|
128
214
|
RiCal can parse icalendar data from either a string or a Ruby io object.
|
|
129
215
|
|
|
130
|
-
The data may consist of one or more icalendar calendars, or one or more icalendar components (e.g.
|
|
131
|
-
VEVENT, or VTODO objects.)
|
|
216
|
+
The data may consist of one or more icalendar calendars, or one or more icalendar components (e.g.
|
|
217
|
+
one or more VEVENT, or VTODO objects.)
|
|
132
218
|
|
|
133
219
|
In either case the result will be an array of components.
|
|
134
220
|
==== From a string
|
data/Rakefile
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#- ©2009 Rick DeNatale
|
|
2
2
|
#- All rights reserved. Refer to the file README.txt for the license
|
|
3
3
|
#
|
|
4
|
-
%w[rubygems rake rake/clean fileutils newgem
|
|
4
|
+
%w[rubygems rake rake/clean fileutils newgem].each { |f| require f }
|
|
5
5
|
require File.dirname(__FILE__) + '/lib/ri_cal'
|
|
6
6
|
|
|
7
7
|
# Generate all the Rake tasks
|
data/copyrights.txt
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
©2009 Rick DeNatale
|
|
2
|
-
All rights reserved. Refer to the file README.txt for the license
|
|
1
|
+
©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
|
|
@@ -3,8 +3,7 @@ require File.join(File.dirname(__FILE__), %w[.. properties alarm.rb])
|
|
|
3
3
|
module RiCal
|
|
4
4
|
|
|
5
5
|
class Component
|
|
6
|
-
#- ©2009 Rick DeNatale
|
|
7
|
-
#- All rights reserved. Refer to the file README.txt for the license
|
|
6
|
+
#- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
|
|
8
7
|
#
|
|
9
8
|
# An Alarm component groups properties defining a reminder or alarm associated with an event or to-do
|
|
10
9
|
# TODO: The Alarm component has complex cardinality restrictions depending on the value of the action property
|
|
@@ -2,8 +2,7 @@ require File.join(File.dirname(__FILE__), %w[.. properties calendar.rb])
|
|
|
2
2
|
|
|
3
3
|
module RiCal
|
|
4
4
|
class Component
|
|
5
|
-
#- ©2009 Rick DeNatale
|
|
6
|
-
#- All rights reserved. Refer to the file README.txt for the license
|
|
5
|
+
#- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
|
|
7
6
|
#
|
|
8
7
|
# to see the property accessing methods for this class see the RiCal::Properties::Calendar module
|
|
9
8
|
class Calendar < Component
|
|
@@ -51,6 +50,17 @@ module RiCal
|
|
|
51
50
|
result
|
|
52
51
|
end
|
|
53
52
|
|
|
53
|
+
# Return the default time zone identifier for this calendar
|
|
54
|
+
def default_tzid
|
|
55
|
+
@default_tzid || PropertyValue::DateTime.default_tzid
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Set the default time zone identifier for this calendar
|
|
59
|
+
# To set the default to floating times use a value of :floating
|
|
60
|
+
def default_tzid=(value)
|
|
61
|
+
@default_tzid=value
|
|
62
|
+
end
|
|
63
|
+
|
|
54
64
|
# return an array of event components contained within this Calendar
|
|
55
65
|
def events
|
|
56
66
|
subcomponents["VEVENT"]
|
|
@@ -77,7 +87,7 @@ module RiCal
|
|
|
77
87
|
subcomponents["VFREEBUSY"]
|
|
78
88
|
end
|
|
79
89
|
|
|
80
|
-
class TimezoneID
|
|
90
|
+
class TimezoneID #:nodoc:
|
|
81
91
|
attr_reader :identifier, :calendar
|
|
82
92
|
def initialize(identifier, calendar)
|
|
83
93
|
self.identifier, self.calendar = identifier, calendar
|
|
@@ -100,29 +110,35 @@ module RiCal
|
|
|
100
110
|
def timezones
|
|
101
111
|
subcomponents["VTIMEZONE"]
|
|
102
112
|
end
|
|
103
|
-
|
|
113
|
+
|
|
104
114
|
class TZInfoWrapper #:nodoc:
|
|
105
115
|
attr_reader :tzinfo, :calendar #:nodoc:
|
|
106
116
|
def initialize(tzinfo, calendar) #:nodoc:
|
|
107
117
|
@tzinfo = tzinfo
|
|
108
118
|
@calendar = calendar
|
|
109
119
|
end
|
|
110
|
-
|
|
120
|
+
|
|
111
121
|
def identifier #:nodoc:
|
|
112
122
|
tzinfo.identifier
|
|
113
123
|
end
|
|
114
|
-
|
|
124
|
+
|
|
115
125
|
def date_time(ruby_time, tzid) #:nodoc:
|
|
116
126
|
RiCal::PropertyValue::DateTime.new(calendar, :value => ruby_time, :params => {'TZID' => tzid})
|
|
117
127
|
end
|
|
118
|
-
|
|
128
|
+
|
|
119
129
|
def local_to_utc(utc) #:nodoc:
|
|
120
130
|
date_time(tzinfo.local_to_utc(utc.to_ri_cal_ruby_value), 'UTC')
|
|
121
131
|
end
|
|
122
|
-
|
|
132
|
+
|
|
123
133
|
def utc_to_local(local) #:nodoc:
|
|
124
134
|
date_time(tzinfo.utc_to_local(local.to_ri_cal_ruby_value), tzinfo.identifier)
|
|
125
135
|
end
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def rational_utc_offset(local)
|
|
139
|
+
Rational(tzinfo.period_for_local(local, true).utc_offset, 3600) / 24
|
|
140
|
+
end
|
|
141
|
+
|
|
126
142
|
end
|
|
127
143
|
|
|
128
144
|
def find_timezone(identifier) #:nodoc:
|
|
@@ -135,7 +151,7 @@ module RiCal
|
|
|
135
151
|
else
|
|
136
152
|
result = timezones.find {|tz| tz.tzid == identifier}
|
|
137
153
|
raise RiCal::InvalidTimezoneIdentifier.not_found_in_calendar(identifier) unless result
|
|
138
|
-
result
|
|
154
|
+
result
|
|
139
155
|
end
|
|
140
156
|
end
|
|
141
157
|
|
|
@@ -2,8 +2,7 @@ require File.join(File.dirname(__FILE__), %w[.. properties event.rb])
|
|
|
2
2
|
|
|
3
3
|
module RiCal
|
|
4
4
|
class Component
|
|
5
|
-
#- ©2009 Rick DeNatale
|
|
6
|
-
#- All rights reserved. Refer to the file README.txt for the license
|
|
5
|
+
#- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
|
|
7
6
|
#
|
|
8
7
|
# An Event (VEVENT) calendar component groups properties describing a scheduled event.
|
|
9
8
|
# Events may have multiple occurrences
|
|
@@ -2,8 +2,7 @@ require File.join(File.dirname(__FILE__), %w[.. properties freebusy.rb])
|
|
|
2
2
|
|
|
3
3
|
module RiCal
|
|
4
4
|
class Component
|
|
5
|
-
#- ©2009 Rick DeNatale
|
|
6
|
-
#- All rights reserved. Refer to the file README.txt for the license
|
|
5
|
+
#- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
|
|
7
6
|
#
|
|
8
7
|
# A Freebusy (VFREEBUSY) calendar component groups properties describing either a request for free/busy time,
|
|
9
8
|
# a response to a request for free/busy time, or a published set of busy time.
|
|
@@ -3,8 +3,7 @@ require File.join(File.dirname(__FILE__), %w[.. properties journal.rb])
|
|
|
3
3
|
|
|
4
4
|
module RiCal
|
|
5
5
|
class Component
|
|
6
|
-
#- ©2009 Rick DeNatale
|
|
7
|
-
#- All rights reserved. Refer to the file README.txt for the license
|
|
6
|
+
#- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
|
|
8
7
|
#
|
|
9
8
|
# A Journal (VJOURNAL) calendar component groups properties describing a journal entry.
|
|
10
9
|
# Journals may have multiple occurrences
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
#- ©2009 Rick DeNatale
|
|
2
|
-
#- All rights reserved. Refer to the file README.txt for the license
|
|
1
|
+
#- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
|
|
3
2
|
#
|
|
4
3
|
# A wrapper class for a Timezone implemented by the TZInfo Gem
|
|
5
4
|
# (or by Rails)
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
module RiCal
|
|
2
2
|
class Component
|
|
3
3
|
class Timezone
|
|
4
|
-
#- ©2009 Rick DeNatale
|
|
5
|
-
#- All rights reserved. Refer to the file README.txt for the license
|
|
4
|
+
#- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
|
|
6
5
|
#
|
|
7
6
|
# A DaylightPeriod is a TimezonePeriod during which daylight saving time *is* in effect
|
|
8
7
|
class DaylightPeriod < TimezonePeriod #:nodoc: all
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
module RiCal
|
|
2
2
|
class Component
|
|
3
3
|
class Timezone
|
|
4
|
-
#- ©2009 Rick DeNatale
|
|
5
|
-
#- All rights reserved. Refer to the file README.txt for the license
|
|
4
|
+
#- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
|
|
6
5
|
#
|
|
7
6
|
# A StandardPeriod is a TimezonePeriod during which daylight saving time is *not* in effect
|
|
8
7
|
class StandardPeriod < TimezonePeriod #:nodoc: all
|
|
@@ -3,8 +3,7 @@ require File.join(File.dirname(__FILE__), %w[.. .. properties timezone_period.rb
|
|
|
3
3
|
module RiCal
|
|
4
4
|
class Component
|
|
5
5
|
class Timezone
|
|
6
|
-
#- ©2009 Rick DeNatale
|
|
7
|
-
#- All rights reserved. Refer to the file README.txt for the license
|
|
6
|
+
#- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
|
|
8
7
|
#
|
|
9
8
|
# A TimezonePeriod is a component of a timezone representing a period during which a particular offset from UTC is
|
|
10
9
|
# in effect.
|
|
@@ -2,8 +2,7 @@ require File.join(File.dirname(__FILE__), %w[.. properties timezone.rb])
|
|
|
2
2
|
|
|
3
3
|
module RiCal
|
|
4
4
|
class Component
|
|
5
|
-
#- ©2009 Rick DeNatale
|
|
6
|
-
#- All rights reserved. Refer to the file README.txt for the license
|
|
5
|
+
#- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
|
|
7
6
|
#
|
|
8
7
|
# An Timezone (VTIMEZONE) calendar component describes a timezone used within the calendar.
|
|
9
8
|
# A Timezone has two or more TimezonePeriod subcomponents which describe the transitions between
|
|
@@ -23,6 +22,10 @@ module RiCal
|
|
|
23
22
|
# Don't use alias, as identifier gets overridden.
|
|
24
23
|
identifier
|
|
25
24
|
end
|
|
25
|
+
|
|
26
|
+
def rational_utc_offset(local) #:nodoc:
|
|
27
|
+
Rational(period_for_local(local, true).utc_offset, 3600) / 24
|
|
28
|
+
end
|
|
26
29
|
|
|
27
30
|
# Returns the TimezonePeriod for the given UTC time. utc can either be a DateTime,
|
|
28
31
|
# Time or integer timestamp (Time.to_i). Any timezone information in utc is ignored (it is treated as a UTC time).
|
data/lib/ri_cal/component.rb
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
module RiCal
|
|
2
|
-
#- ©2009 Rick DeNatale
|
|
3
|
-
#- All rights reserved. Refer to the file README.txt for the license
|
|
2
|
+
#- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
|
|
4
3
|
#
|
|
5
|
-
class Component
|
|
4
|
+
class Component #:nodoc:
|
|
6
5
|
class ComponentBuilder #:nodoc:
|
|
7
6
|
def initialize(component)
|
|
8
7
|
@component = component
|
|
@@ -46,11 +45,27 @@ module RiCal
|
|
|
46
45
|
end
|
|
47
46
|
end
|
|
48
47
|
|
|
49
|
-
def
|
|
50
|
-
@parent
|
|
48
|
+
def default_tzid #:nodoc:
|
|
49
|
+
if @parent
|
|
50
|
+
@parent.default_tzid
|
|
51
|
+
else
|
|
52
|
+
PropertyValue::DateTime.default_tzid
|
|
53
|
+
end
|
|
51
54
|
end
|
|
52
55
|
|
|
53
|
-
def
|
|
56
|
+
def find_timezone(identifier) #:nodoc:
|
|
57
|
+
if @parent
|
|
58
|
+
@parent.find_timezone(identifier)
|
|
59
|
+
else
|
|
60
|
+
begin
|
|
61
|
+
Calendar::TZInfoWrapper.new(TZInfo::Timezone.get(identifier), self)
|
|
62
|
+
rescue ::TZInfo::InvalidTimezoneIdentifier => ex
|
|
63
|
+
raise RiCal::InvalidTimezoneIdentifier.invalid_tzinfo_identifier(identifier)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def time_zone_for(ruby_object) #:nodoc:
|
|
54
69
|
@parent.time_zone_for(ruby_object) #:nodoc:
|
|
55
70
|
end
|
|
56
71
|
|
|
@@ -127,7 +142,7 @@ module RiCal
|
|
|
127
142
|
x_properties[name] = prop
|
|
128
143
|
end
|
|
129
144
|
|
|
130
|
-
def method_missing(selector, *args, &b)
|
|
145
|
+
def method_missing(selector, *args, &b) #:nodoc:
|
|
131
146
|
xprop_candidate = selector.to_s
|
|
132
147
|
if (match = /^x_(.+)(=?)$/.match(xprop_candidate))
|
|
133
148
|
if match[2] == "="
|
|
@@ -4,22 +4,23 @@ module RiCal
|
|
|
4
4
|
#- ©2009 Rick DeNatale
|
|
5
5
|
#- All rights reserved. Refer to the file README.txt for the license
|
|
6
6
|
#
|
|
7
|
-
module Conversions
|
|
7
|
+
module Conversions #:nodoc:
|
|
8
8
|
# Return an RiCal::PropertyValue::DateTime representing the receiver
|
|
9
|
-
def to_ri_cal_date_time_value
|
|
10
|
-
RiCal::PropertyValue::DateTime.new(
|
|
9
|
+
def to_ri_cal_date_time_value(timezone_finder = nil)
|
|
10
|
+
RiCal::PropertyValue::DateTime.new(timezone_finder, :value => self)
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
# Return an RiCal::PropertyValue::Date representing the receiver
|
|
14
|
-
def to_ri_cal_date_value
|
|
15
|
-
RiCal::PropertyValue::Date.new(
|
|
14
|
+
def to_ri_cal_date_value(timezone_finder = nil)
|
|
15
|
+
RiCal::PropertyValue::Date.new(timezone_finder, :value => self)
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
alias_method :to_ri_cal_date_or_date_time_value, :to_ri_cal_date_value
|
|
19
|
+
alias_method :to_ri_cal_occurrence_list_value, :to_ri_cal_date_value
|
|
19
20
|
|
|
20
21
|
# Return the natural ri_cal_property for this object
|
|
21
|
-
def to_ri_cal_property_value
|
|
22
|
-
to_ri_cal_date_value
|
|
22
|
+
def to_ri_cal_property_value(timezone_finder = nil)
|
|
23
|
+
to_ri_cal_date_value(timezone_finder)
|
|
23
24
|
end
|
|
24
25
|
end
|
|
25
26
|
end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
require "#{File.dirname(__FILE__)}/
|
|
1
|
+
require "#{File.dirname(__FILE__)}/time/conversions.rb"
|
|
2
|
+
require "#{File.dirname(__FILE__)}/time/tzid_access.rb"
|
|
2
3
|
require "#{File.dirname(__FILE__)}/time/week_day_predicates.rb"
|
|
3
4
|
require "#{File.dirname(__FILE__)}/time/calculations.rb"
|
|
4
5
|
require 'date'
|
|
@@ -9,5 +10,6 @@ class DateTime #:nodoc:
|
|
|
9
10
|
#
|
|
10
11
|
include RiCal::CoreExtensions::Time::WeekDayPredicates
|
|
11
12
|
include RiCal::CoreExtensions::Time::Calculations
|
|
12
|
-
include RiCal::CoreExtensions::
|
|
13
|
+
include RiCal::CoreExtensions::Time::TzidAccess
|
|
14
|
+
include RiCal::CoreExtensions::Time::Conversions
|
|
13
15
|
end
|