Skip to content
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

ICS files for subscribing in Calendar #219

Merged
merged 5 commits into from
Jan 23, 2020
Merged

ICS files for subscribing in Calendar #219

merged 5 commits into from
Jan 23, 2020

Conversation

davedelong
Copy link
Collaborator

Implements #215

This adds three files to the generated site: /api/all.ics, /api/cocoa.ics, and /api/mobile.ics.

Every time the site is re-built, the three files are generated. They allow users to see all the conferences (or only cocoa conferences, or only mobile conferences) in their calendaring app of choice.

I've verified that the ICS files can be correctly read by Calendar.app.

Screen Shot 2020-01-22 at 5 29 00 PM

@davedelong
Copy link
Collaborator Author

Screen Shot 2020-01-22 at 5 30 01 PM

@davedelong
Copy link
Collaborator Author

Actually, I just noticed an issue. Conferences are showing up as one day too short. UIKonf (for example) should be 4 days long, not 3.

@davedelong
Copy link
Collaborator Author

Aha, I think I figured this out.

In iCalendar files, all day events start on one day (ex: 20200122) but end on the next day (ex: 20200123). Therefore, I basically need to add 1 to the end day of every date.

HOWEVER, this could cause issues (for example) if a conference occurs on Mar 30 - Mar 31, then the file generated would say it ended on 20200332 (Mar 32), which is obviously Not Great™.

I'm wondering if I want to try figuring out the syntax for "proper" date incrementing in Liquid 🤪

@AliSoftware
Copy link

AliSoftware commented Jan 23, 2020

Nice addition!

There's the | date: "<format>" filter in liquid so maybe you can use that to convert the yyyy-MM-dd string into a timestamp, then do number math on that number to add one day, then convert back?

The math will likely involve adding 86400 to the timestamp, so not perfect (DST and all) but more correct than adding 1 to the day number at least


Side note / PS: would be nice to use that same ics template to also generate one ics per event and add a link to download it next to each conference in the list, to be able to easily just add the conference(s) one would be interested in instead of all at once

@AliSoftware
Copy link

AliSoftware commented Jan 23, 2020

i.e. probably something that would look like this in the template? (⚠️GINAC)

conference.end | date:"%s" | plus:86400 | date:"%Y%m%d"

iCalendar format is a bit strange with how it deals with dates. A date in a field is that starting _instant_ of when a thing starts or ends. Therefore an event that starts at `2020-01-22` and ends at `2020-01-22` has a length of "0". Conventionally we think it would mean "one day", but that's not how iCalendar format works. Therefore, we need to shift the end date _forward_ a day to represent the first instant of _after_ the event ends. Or in other words, an all-day event on Jan 22 starts at `2020-01-22` and ends at `2020-01-23`.

However, that's not *quite* good enough, because we do have rogue leap hours that mix in. Therefore, we're going to shift forward by 36 hours so we can be sure we're solidly during the "next day" before we try to format it back down to just the year-month-day.
@davedelong
Copy link
Collaborator Author

Thanks @AliSoftware! Based on this I got it working.

I thought of just appending a time to the date fields (eg T000000 to T235959), but that would've made them not be all-day events.

Calendar shows the events happening on the "right" days and they also correctly show up as all-day events for those days.

Screen Shot 2020-01-22 at 7 31 57 PM

Copy link

@AliSoftware AliSoftware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now we just need to add links to download those files 🙂

@mariusc
Copy link
Collaborator

mariusc commented Jan 23, 2020

Amazing work, Dave! Just tested this and it works very well, both imoprting in iCalendar and in Google Calendar (in browser).

As @AliSoftware said, we need to add the links to the calendars :). Let me know if you need help with that, I'd like to get this update merged in the next 10-12 hours so I can give it a shoutout in today's issue of iOS Goodies 😁

@BasThomas
Copy link
Contributor

Woah, so cool! Thanks @davedelong. Some great learnings about iCal, too 😄

Initial include of calendar files
@mariusc
Copy link
Collaborator

mariusc commented Jan 23, 2020

Merged the PR from @BasThomas which adds the links to the site. And now also merging this. Great suggestion, @BasThomas, and awesome work @davedelong!

@mariusc mariusc merged commit a3ef130 into master Jan 23, 2020
@mariusc mariusc deleted the ics-files branch January 23, 2020 08:50
@Lascorbe
Copy link
Owner

This is AMAZING!! Thank you @davedelong, @BasThomas, @AliSoftware and @mariusc! 👏 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants