icalendar 2.13.0 → 2.14.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +37 -0
- data/icalendar.gemspec +1 -0
- data/lib/icalendar/calendar.rb +98 -0
- data/lib/icalendar/timezone.rb +61 -1
- data/lib/icalendar/timezone_history.rb +94 -0
- data/lib/icalendar/transition_rule_sample.rb +58 -0
- data/lib/icalendar/tzinfo.rb +65 -3
- data/lib/icalendar/version.rb +1 -1
- data/spec/timezone_merging_spec.rb +595 -0
- data/spec/transition_rule_sample_spec.rb +81 -0
- data/spec/tzinfo_future_recurrence_spec.rb +98 -0
- metadata +23 -1
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require_relative '../lib/icalendar/tzinfo'
|
|
3
|
+
|
|
4
|
+
describe 'TZInfo-generated calendar future transition semantics' do
|
|
5
|
+
def round_trip(zone, reference)
|
|
6
|
+
calendar = Icalendar::Calendar.new
|
|
7
|
+
calendar.add_timezone zone.ical_timezone(reference)
|
|
8
|
+
Icalendar::Calendar.parse(calendar.to_ical).first.timezones.first
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
[DateTime.new(2026, 10, 7), DateTime.new(2030, 6, 1)].each do |reference|
|
|
12
|
+
[4, 9].each do |month|
|
|
13
|
+
it "preserves Santiago month #{month} boundaries generated on #{reference}" do
|
|
14
|
+
zone = TZInfo::Timezone.get('America/Santiago')
|
|
15
|
+
parsed = round_trip(zone, reference)
|
|
16
|
+
((reference.year + 1)..(reference.year + 20)).each do |year|
|
|
17
|
+
(1..10).each do |day|
|
|
18
|
+
local = DateTime.new(year, month, day, 12)
|
|
19
|
+
expect(parsed.offset_for_local(local).value_ical).to eq(zone.period_for_local(local).offset.ical_offset),
|
|
20
|
+
"#{reference} -> #{local}: parsed ICS must match TZInfo"
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
[[2029, 4, :standards], [2030, 9, :daylights]].each do |year, month, kind|
|
|
28
|
+
it "uses the weekday/monthday intersection in #{year}-#{month}" do
|
|
29
|
+
zone = TZInfo::Timezone.get('America/Santiago')
|
|
30
|
+
parsed = round_trip(zone, DateTime.new(2026, 10, 7))
|
|
31
|
+
component = parsed.public_send(kind).first
|
|
32
|
+
rule = component.rrule.first.value_ical
|
|
33
|
+
expect(rule).to include('BYDAY=SU')
|
|
34
|
+
expect(rule).to include('BYMONTHDAY=2,3,4,5,6,7,8')
|
|
35
|
+
schedule = IceCube::Schedule.new(Time.utc(year, 1, 1))
|
|
36
|
+
schedule.add_recurrence_rule IceCube::Rule.from_ical(rule)
|
|
37
|
+
occurrences = schedule.occurrences_between(Time.utc(year, month, 1), Time.utc(year, month, 10))
|
|
38
|
+
expect(occurrences.map { |time| [time.year, time.month, time.day] }).to eq([[year, month, 8]])
|
|
39
|
+
[1, 7, 8, 9].each do |day|
|
|
40
|
+
local = DateTime.new(year, month, day, 12)
|
|
41
|
+
expect(parsed.offset_for_local(local).value_ical).to eq(zone.period_for_local(local).offset.ical_offset)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
['Europe/Copenhagen', 'America/Los_Angeles', 'Australia/Lord_Howe'].each do |identifier|
|
|
47
|
+
it "retains onset and adjacent-day behavior for #{identifier}" do
|
|
48
|
+
zone = TZInfo::Timezone.get(identifier)
|
|
49
|
+
generated = zone.ical_timezone(DateTime.new(2026, 1, 1))
|
|
50
|
+
parsed = round_trip(zone, DateTime.new(2026, 1, 1))
|
|
51
|
+
period = zone.period_for_local(DateTime.new(2026, 1, 1))
|
|
52
|
+
[period.start_transition, period.end_transition].each do |transition|
|
|
53
|
+
onset = (transition.respond_to?(:local_end_at) ? transition.local_end_at : transition.local_end).to_datetime
|
|
54
|
+
component = (generated.daylights + generated.standards).find { |item| item.dtstart.value_ical == onset.strftime('%Y%m%dT%H%M%S') }
|
|
55
|
+
expect(component).not_to be_nil
|
|
56
|
+
expect(component.tzoffsetfrom.value_ical).to eq(transition.previous_offset.ical_offset)
|
|
57
|
+
expect(component.tzoffsetto.value_ical).to eq(transition.offset.ical_offset)
|
|
58
|
+
end
|
|
59
|
+
zone.transitions_up_to(Time.utc(2032), Time.utc(2027)).each do |transition|
|
|
60
|
+
onset = (transition.respond_to?(:local_end_at) ? transition.local_end_at : transition.local_end).to_datetime
|
|
61
|
+
[-1, 0, 1].each do |delta|
|
|
62
|
+
date = onset.to_date + delta
|
|
63
|
+
local = DateTime.new(date.year, date.month, date.day, 12)
|
|
64
|
+
expect(parsed.offset_for_local(local).value_ical).to eq(zone.period_for_local(local).offset.ical_offset)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
it 'trims UTC query padding by local onset year, keeping both local boundaries' do
|
|
71
|
+
zone = TZInfo::Timezone.get('America/Santiago')
|
|
72
|
+
reference = DateTime.new(2026, 10, 7)
|
|
73
|
+
transition_type = Struct.new(:local_end)
|
|
74
|
+
before = transition_type.new(DateTime.new(2025, 12, 31, 23))
|
|
75
|
+
first = transition_type.new(DateTime.new(2026, 1, 1))
|
|
76
|
+
last = transition_type.new(DateTime.new(2053, 12, 31, 23))
|
|
77
|
+
after = transition_type.new(DateTime.new(2054, 1, 1))
|
|
78
|
+
expect(zone).to receive(:transitions_up_to).
|
|
79
|
+
with(Time.utc(2054, 1, 3), Time.utc(2025, 12, 30)).
|
|
80
|
+
and_return([before, first, last, after])
|
|
81
|
+
expect(Icalendar::TransitionRuleSample).to receive(:rules).
|
|
82
|
+
with([first, last], anything, 2026, 28).and_return(nil)
|
|
83
|
+
|
|
84
|
+
zone.ical_timezone(reference)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
it 'retains the legacy path when transitions_up_to is unavailable' do
|
|
88
|
+
zone = TZInfo::Timezone.get('America/Santiago')
|
|
89
|
+
reference = DateTime.new(2026, 10, 7)
|
|
90
|
+
period = zone.period_for_local(reference)
|
|
91
|
+
allow(zone).to receive(:respond_to?).and_call_original
|
|
92
|
+
allow(zone).to receive(:respond_to?).with(:transitions_up_to).and_return(false)
|
|
93
|
+
expect(zone).not_to receive(:transitions_up_to)
|
|
94
|
+
generated = zone.ical_timezone(reference)
|
|
95
|
+
expect(generated.daylights.first.rrule.first.value_ical).to eq(period.daylight.rrule.first.value_ical)
|
|
96
|
+
expect(generated.standards.first.rrule.first.value_ical).to eq(period.standard.rrule.first.value_ical)
|
|
97
|
+
end
|
|
98
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: icalendar
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.14.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ryan Ahearn
|
|
@@ -121,6 +121,20 @@ dependencies:
|
|
|
121
121
|
- - "~>"
|
|
122
122
|
- !ruby/object:Gem::Version
|
|
123
123
|
version: '1.2020'
|
|
124
|
+
- !ruby/object:Gem::Dependency
|
|
125
|
+
name: irb
|
|
126
|
+
requirement: !ruby/object:Gem::Requirement
|
|
127
|
+
requirements:
|
|
128
|
+
- - ">="
|
|
129
|
+
- !ruby/object:Gem::Version
|
|
130
|
+
version: '0'
|
|
131
|
+
type: :development
|
|
132
|
+
prerelease: false
|
|
133
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
134
|
+
requirements:
|
|
135
|
+
- - ">="
|
|
136
|
+
- !ruby/object:Gem::Version
|
|
137
|
+
version: '0'
|
|
124
138
|
- !ruby/object:Gem::Dependency
|
|
125
139
|
name: timecop
|
|
126
140
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -217,8 +231,10 @@ files:
|
|
|
217
231
|
- lib/icalendar/offset/windows_to_iana.rb
|
|
218
232
|
- lib/icalendar/parser.rb
|
|
219
233
|
- lib/icalendar/timezone.rb
|
|
234
|
+
- lib/icalendar/timezone_history.rb
|
|
220
235
|
- lib/icalendar/timezone_store.rb
|
|
221
236
|
- lib/icalendar/todo.rb
|
|
237
|
+
- lib/icalendar/transition_rule_sample.rb
|
|
222
238
|
- lib/icalendar/tzinfo.rb
|
|
223
239
|
- lib/icalendar/value.rb
|
|
224
240
|
- lib/icalendar/values/binary.rb
|
|
@@ -270,8 +286,11 @@ files:
|
|
|
270
286
|
- spec/parser_spec.rb
|
|
271
287
|
- spec/roundtrip_spec.rb
|
|
272
288
|
- spec/spec_helper.rb
|
|
289
|
+
- spec/timezone_merging_spec.rb
|
|
273
290
|
- spec/timezone_spec.rb
|
|
274
291
|
- spec/todo_spec.rb
|
|
292
|
+
- spec/transition_rule_sample_spec.rb
|
|
293
|
+
- spec/tzinfo_future_recurrence_spec.rb
|
|
275
294
|
- spec/tzinfo_spec.rb
|
|
276
295
|
- spec/values/date_or_date_time_spec.rb
|
|
277
296
|
- spec/values/date_spec.rb
|
|
@@ -341,8 +360,11 @@ test_files:
|
|
|
341
360
|
- spec/parser_spec.rb
|
|
342
361
|
- spec/roundtrip_spec.rb
|
|
343
362
|
- spec/spec_helper.rb
|
|
363
|
+
- spec/timezone_merging_spec.rb
|
|
344
364
|
- spec/timezone_spec.rb
|
|
345
365
|
- spec/todo_spec.rb
|
|
366
|
+
- spec/transition_rule_sample_spec.rb
|
|
367
|
+
- spec/tzinfo_future_recurrence_spec.rb
|
|
346
368
|
- spec/tzinfo_spec.rb
|
|
347
369
|
- spec/values/date_or_date_time_spec.rb
|
|
348
370
|
- spec/values/date_spec.rb
|