Last active
November 6, 2019 04:24
-
-
Save atsmith813/da69046d07436b633a4df8b024a49836 to your computer and use it in GitHub Desktop.
Import .ics file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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