0.0
No commit activity in last 3 years
No release in over 3 years
Create a calendar of date and time events and execute code based on which events are currently happening.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

> 0.0.0
 Project Readme

Create a calendar of date and time events, attach arbitrary objects to them
and ask which objects are current at any point in time.

Uses the flexible time parsing of Time.parse to be easy to use and the
timezone and DST handling of tzinfo.

Originally conceived for making web sites look and behave differently depending
on the time of day or year.

Example (print holiday greetings):


require 'seasonal'

holidays = Seasonal::Calendar.new

holidays.push(Seasonal::Event.new('Merry Christmas', 'America/New_York',
  :on => 'dec 25'))
holidays.push(Seasonal::Event.new("April Fool's Day", 'America/New_York',
  :on => 'apr 1'))

holidays.going_on { |e| puts e }

Example (make text red between 9:00 and 10:00 am):


require 'seasonal'

colors = Seasonal::Calendar.new

colors.push(Seasonal::Event.new('#ff0000', 'America/New_York',
  :start => '9:00am', :end => '10:00am'))

color = colors.going_on(:or_if_none => '#000000')
puts "<p style=\"background-color : #{color}\">test</p>"

Example (sale ends Jul 10):


require 'seasonal'

sales = Seasonal::Calendar.new

sales.push(Seasonal::Event.new('Everything on sale', 'America/New_York',
  :end => 'jul 10 2009'))

sales.going_on { |e| puts e }