-
Notifications
You must be signed in to change notification settings - Fork 358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Time zone support in schedule_from_ical
#526
base: master
Are you sure you want to change the base?
Changes from all commits
ee6ce49
740125c
f1d7f6e
3a4ab88
afa978a
c3a7ede
c607f17
e91465a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -348,6 +348,69 @@ def sorted_ical(ical) | |
end | ||
end | ||
|
||
describe "time zone support" do | ||
it "parses start time with the correct time zone" do | ||
schedule = IceCube::Schedule.from_ical ical_string_with_multiple_rules | ||
|
||
expect(schedule.start_time).to eq Time.find_zone!("America/Chicago").local(2015, 10, 5, 19, 55, 41) | ||
end | ||
|
||
it "parses time zones correctly" do | ||
schedule = IceCube::Schedule.from_ical ical_string_with_multiple_exdates_and_rdates | ||
|
||
utc_times = [ | ||
schedule.recurrence_rules.map(&:until_time) | ||
].flatten | ||
|
||
denver_times = [ | ||
schedule.start_time, | ||
schedule.end_time, | ||
schedule.exception_times, | ||
schedule.rtimes | ||
].flatten | ||
|
||
utc_times.each do |t| | ||
expect(t.zone).to eq "UTC" | ||
end | ||
|
||
denver_times.each do |t| | ||
expect(t.zone).to eq "MDT" | ||
end | ||
end | ||
|
||
it "round trips from and to ical with time zones in the summer (MDT)" do | ||
original = <<-ICAL.gsub(/^\s*/, "").strip | ||
DTSTART;TZID=MDT:20130731T143000 | ||
RRULE:FREQ=WEEKLY;UNTIL=20140730T203000Z;BYDAY=MO,WE,FR | ||
RDATE;TZID=MDT:20150812T143000 | ||
RDATE;TZID=MDT:20150807T143000 | ||
EXDATE;TZID=MDT:20130823T143000 | ||
EXDATE;TZID=MDT:20130812T143000 | ||
EXDATE;TZID=MDT:20130807T143000 | ||
DTEND;TZID=MDT:20130731T153000 | ||
ICAL | ||
|
||
schedule_from_ical = IceCube::Schedule.from_ical original | ||
expect(schedule_from_ical.to_ical).to eq original | ||
end | ||
Comment on lines
+381
to
+395
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This may seem like a superfluous test compared to the one below, but before the last commit on this branch, this test would have failed when run during the winter (standard time vs. daylight saving time period). I tested this using Timecop locally, but I didn't want to add a dependency to your repository just for this PR, so I didn't commit that part. |
||
|
||
it "round trips from and to ical with time zones in the winter (MST)" do | ||
original = <<-ICAL.gsub(/^\s*/, "").strip | ||
DTSTART;TZID=MST:20130131T143000 | ||
RRULE:FREQ=WEEKLY;UNTIL=20140130T203000Z;BYDAY=MO,WE,FR | ||
RDATE;TZID=MST:20150212T143000 | ||
RDATE;TZID=MST:20150207T143000 | ||
EXDATE;TZID=MST:20130223T143000 | ||
EXDATE;TZID=MST:20130212T143000 | ||
EXDATE;TZID=MST:20130207T143000 | ||
DTEND;TZID=MST:20130131T153000 | ||
ICAL | ||
|
||
schedule_from_ical = IceCube::Schedule.from_ical original | ||
expect(schedule_from_ical.to_ical).to eq original | ||
end | ||
end | ||
|
||
describe "exceptions" do | ||
it "handles single EXDATE lines, single RDATE lines" do | ||
start_time = Time.now | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This
_tzid
contained the ignored time zone information.