weekday

This gem calculates date like 'first tuesday in december 2010' or 'third friday in may 2011' or 'last Saturday in december 2010'

Support this project

If you find this gem useful and you want to support this work, send Bitcoins to the address 1ASyu5EuTkUEmiNz3y2ikSDAjdySpDJSMb.

Features

  • All method names are a combination of 'first', 'second', 'third', 'fourth', 'fifth' and 'monday', 'tuesday', ...
  • Also 'last' + 'monday', 'tuesday', ... is possible
  • All methods require two arguments for the year and the month
  • If there is for example no fifth saturday in a specific month then nil is returned

Examples

require 'rubygems'
require 'weekday'

1.upto 12 do |month|
  day = Weekday.first_thursday(2010, month)
  puts day
end

Install

  • [sudo] gem install weekday

Author

Original author: Thomas Preymesser

License

(The MIT License)

Copyright (c) 2010 Thomas Preymesser

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.