2007-11-20 20:54:55 +01:00
|
|
|
= Ruby Holidays Gem
|
2007-11-20 01:58:20 +01:00
|
|
|
|
2007-11-22 21:39:26 +01:00
|
|
|
A set of classes to deal with holidays in Ruby.
|
2007-11-20 01:58:20 +01:00
|
|
|
|
2007-11-20 20:54:55 +01:00
|
|
|
Extends Ruby's built-in Date class and supports custom holiday definition lists.
|
|
|
|
|
|
|
|
=== Examples
|
|
|
|
|
|
|
|
==== Using the Holidays class
|
|
|
|
# Get all holidays on April 25, 2008 in Australia
|
|
|
|
date = Date.civil(2008,4,25)
|
|
|
|
Holidays.by_day(date, :au)
|
|
|
|
=> [{:name => 'ANZAC Day',...}]
|
2007-11-20 01:58:20 +01:00
|
|
|
|
|
|
|
|
2007-11-20 20:54:55 +01:00
|
|
|
# Get all holidays in July, 2008 in Canada and the US
|
|
|
|
from = Date.civil(2008,7,1)
|
|
|
|
to = Date.civil(2008,7,31)
|
2007-11-30 01:49:33 +01:00
|
|
|
Holidays.between(from, to, :ca,:us)
|
2007-11-20 20:54:55 +01:00
|
|
|
=> [{:name => 'Canada Day',...}
|
2007-11-30 01:49:33 +01:00
|
|
|
{:name => 'Independence Day',...}]
|
2007-11-20 20:54:55 +01:00
|
|
|
|
|
|
|
|
|
|
|
==== Extending Ruby's Date class
|
|
|
|
# Lookup Canada Day in the :ca region
|
2007-11-25 00:22:10 +01:00
|
|
|
Date.civil(2008,7,1).holiday?(:ca)
|
2007-11-20 20:54:55 +01:00
|
|
|
=> true
|
|
|
|
|
|
|
|
# Lookup Canada Day in the :fr region
|
2007-11-25 00:22:10 +01:00
|
|
|
Date.civil(2008,7,1).holiday?(:fr)
|
2007-11-20 20:54:55 +01:00
|
|
|
=> false
|
|
|
|
|
|
|
|
=== Installation
|
2007-11-20 01:58:20 +01:00
|
|
|
|
2007-11-20 20:54:55 +01:00
|
|
|
To install the gem from RubyForge:
|
2007-11-20 01:58:20 +01:00
|
|
|
|
2007-11-20 20:54:55 +01:00
|
|
|
gem install holidays
|
2007-11-20 01:58:20 +01:00
|
|
|
|
2007-11-20 20:54:55 +01:00
|
|
|
Or, download the source <tt>.tgz</tt> file from http://rubyforge.org/holidays/ and
|
|
|
|
extract it somewhere in your include path.
|
2007-11-20 01:58:20 +01:00
|
|
|
|
2007-11-20 20:54:55 +01:00
|
|
|
=== Credits and code
|
2007-11-20 01:58:20 +01:00
|
|
|
|
2007-11-20 20:54:55 +01:00
|
|
|
* Project page: http://code.dunae.ca/holidays
|
|
|
|
* Source: http://code.dunae.ca/svn/holidays
|
|
|
|
* Docs: http://code.dunae.ca/holidays/doc
|
2007-11-20 01:58:20 +01:00
|
|
|
|
2007-11-20 20:54:55 +01:00
|
|
|
By Alex Dunae (dunae.ca, e-mail 'code' at the same domain), 2007.
|
2007-11-20 01:58:20 +01:00
|
|
|
|
2007-11-20 20:54:55 +01:00
|
|
|
Made on Vancouver Island.
|