Skip to content

Instantly share code, notes, and snippets.

@dhgwilliam
Created November 25, 2010 08:23
Show Gist options
  • Save dhgwilliam/715078 to your computer and use it in GitHub Desktop.
Save dhgwilliam/715078 to your computer and use it in GitHub Desktop.
is it shabbos yet microsite
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