Skip to content

Commit 2e866d6

Browse files
epologeeJankees van Woezik
andcommitted
Expose time zone issue when parsing from iCal format
Co-authored-by: Jankees van Woezik <[email protected]>
1 parent 10ae8dc commit 2e866d6

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

spec/examples/from_ical_spec.rb

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,37 @@ def sorted_ical(ical)
348348
end
349349
end
350350

351+
describe "time zones" do
352+
it "parses start time with the correct time zone" do
353+
schedule = IceCube::Schedule.from_ical ical_string_with_multiple_rules
354+
355+
expect(schedule.start_time).to eq Time.find_zone!("America/Chicago").local(2015, 10, 5, 19, 55, 41)
356+
end
357+
358+
it "parses time zones correctly" do
359+
schedule = IceCube::Schedule.from_ical ical_string_with_multiple_exdates_and_rdates
360+
361+
utc_times = [
362+
schedule.recurrence_rules.map(&:until_time)
363+
].flatten
364+
365+
denver_times = [
366+
schedule.start_time,
367+
schedule.end_time,
368+
schedule.exception_times,
369+
schedule.rtimes,
370+
].flatten
371+
372+
utc_times.each do |t|
373+
expect(t.zone).to eq "UTC"
374+
end
375+
376+
denver_times.each do |t|
377+
expect(t.zone).to eq "MDT"
378+
end
379+
end
380+
end
381+
351382
describe "exceptions" do
352383
it "handles single EXDATE lines, single RDATE lines" do
353384
start_time = Time.now

0 commit comments

Comments
 (0)