ice_cube
ice_cube copied to clipboard
Time zone support in `schedule_from_ical`
The base implementation of IceCube::IcalParser.schedule_from_ical
ignores time zone identifiers, resulting in all times being parsed in the current time zone of the host.
This PR exposes the issue with a series of specs, and fixes it with a (somewhat lengthy) time zone lookup. This last part was added because the TZID strings of the iCal format don't map cleanly onto Rails time zones.
Input schedule
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
Output schedule on master
DTSTART;TZID=CEST:20130731T143000
RRULE:FREQ=WEEKLY;UNTIL=20140730T203000Z;BYDAY=MO,WE,FR
RDATE;TZID=CEST:20150812T143000
RDATE;TZID=CEST:20150807T143000
EXDATE;TZID=CEST:20130823T143000
EXDATE;TZID=CEST:20130812T143000
EXDATE;TZID=CEST:20130807T143000
DTEND;TZID=CEST:20130731T153000
Output schedule on this branch
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
P.S. Note that time zones will not always match the exact same string, because something like "America/Denver"
will get converted to "MDT"
along the way. The times will still match semantically.
Hey @epologee, thanks for sending this through!
I'll find some time in the next day or two to review this properly. In the mean time, can you add a changelog entry and ensure your tests pass?
Hi, thanks, will do / already done!
In the mean time, can you add a changelog entry and ensure your tests pass?
standardrb
reports an indentation issue on lines that I did not touch (in a file I did touch), would you like me to add a commit to fix that indentation? Because the workflow needs your approval to run, I'm not sure if it passes or errors right now:
lib/ice_cube/time_util.rb:289:18: Layout/CaseIndentation: Indent `when` as deep as `end`.
lib/ice_cube/time_util.rb:290:18: Layout/CaseIndentation: Indent `when` as deep as `end`.
lib/ice_cube/time_util.rb:291:18: Layout/CaseIndentation: Indent `when` as deep as `end`.
lib/ice_cube/time_util.rb:292:18: Layout/CaseIndentation: Indent `when` as deep as `end`.
lib/ice_cube/time_util.rb:293:18: Layout/CaseIndentation: Indent `when` as deep as `end`.
lib/ice_cube/time_util.rb:294:18: Layout/CaseIndentation: Indent `when` as deep as `end`.
Cheers!
I think once you get your first PR through, you don't need approval for future PR test runs.
would you like me to add a commit to fix that indentation?
Update: I added a commit because the standardrb lint prevents the other tests from running.
Hi - any chance this will be merged ?
We are running this PR in production now, would be great to get this in master.
Can you resolve the failing tests? I'll then do a full review and merge it 👍🏻
Although ... these might be tests that I've broken by reverting another branch 🤔 If so ... I'll hopefully sort it soon, and release everything together.
Hi @pacso, Did you have any chance to review this ?
Hi @pacso Sorry to insist, but is there any way to make it into production ?
Hi @seejohnrun @avit @pacso
I'm wondering... are any of you still maintaining this repo?
Yes, we are. However I sadly don't have time to resolve the issues on this branch. If you can push changes to fix the failing tests, I'll happily merge it.
I pushed a minor edit to re-run the specs. I recall that the failures looked like they weren't created by the changes in this PR, but can have another look after the workflow is approved.