Skip to content

Instantly share code, notes, and snippets.

@atsmith813
Last active November 6, 2019 04:24
Show Gist options
  • Save atsmith813/da69046d07436b633a4df8b024a49836 to your computer and use it in GitHub Desktop.
Save atsmith813/da69046d07436b633a4df8b024a49836 to your computer and use it in GitHub Desktop.
Import .ics file
require 'date'
# This will be the name of your .ics file in the root directory
file_name = 'birthdays.ics'
cal = File.read(file_name).split("BEGIN:VEVENT")
cal.shift # First row is meta data from export
birthdays = []
cal.each do |event|
date = Date.parse(
event.split("DATE:").last
.split("\rDURATION:").first
)
name = event.split("SUMMARY:").last
.split("'s Birthday").first
birthdays << { date: date, name: name }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment