Created
November 25, 2010 08:23
-
-
Save dhgwilliam/715078 to your computer and use it in GitHub Desktop.
is it shabbos yet microsite
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 'sinatra' | |
require 'date' | |
require 'icalendar' | |
require 'net/https' | |
get '/' do | |
is_it_shabbos_yet | |
end | |
helpers do | |
def is_it_shabbos_yet | |
@shabbos = get_shabbos(11211) | |
@is_it = "Nope" | |
# @today = Date.today | |
@today = @shabbos + 1 | |
if @today > @shabbos | |
@is_it = "Yep" | |
end | |
haml :index | |
end | |
def get_shabbos(zipcode) | |
shabbos_ical_url = URI.parse('http://www.chabad.org/calendar/candleliging/candlelighting.ics_cdo/z/' + zipcode.to_s + '/weeks/') | |
shabbos_ical = Net::HTTP.get(shabbos_ical_url) | |
shabbos_ical.slice!(/CHARSET:utf-8\r\n/) | |
shabbos_ical = Icalendar.parse(shabbos_ical) | |
shabbos = shabbos_ical.first.events.first.dtstart | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment