Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A Rails plugin that is making months smarter in Ruby (and Rails).
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
rdoc
test
.gitignore
MIT-LICENSE
README
Rakefile
VERSION
smart_month.gemspec

README

NOTE: Please read the wiki for usage examples and to see how you can help our project!

Big Thanks to JSilver for turning this project into a gem on gemcutter! http://gemcutter.org/gems/smart_month

SmartMonth is a "bodysnatcher" gem that takes boring Date month fixnums and replaces them with a rich toolkit of functionality. You can use SmartMonth to:

- Determine the first tuesday of any month in any year.
- Determine all of the fridays of any month in any year.
- Iterate through all the days of a month.
- Determine how many days of the month there are.
- Determine the first and last days of the month.
- And other fun date/month related things!

This is designed to be an extension of not only Time.now.month, but adds a new Month class to the ruby object model.

Keep in mind, this is 1.1, and may break things that rely on Time.now.month being a Fixnum. I've tried to fix this by making sure #to_i works as expected, but it may be an issue, handle with care.

Examples:

	Time.now.month.every_tuesday #=> [array of tuesdays for the current month]
	Month.april.first_wednesday #=> Date object corresponding to the first wednesday of april.
	Month.may.every_monday_and_friday #=> {:monday=>[...],:friday=>[...]}
	Month.june(2012).last_monday #=> Date object corresponding to the last monday in june 2012.

	# iterator:
	Month.june(2004).each do |day|
		day.to_day #=> name of day (Saturday, Sunday, etc.)
		day.to_i #=> value between 1 and the last day of the month corresponding.
	end

Check the included documentation (rdoc) or the documentation site http://www.derekperez.com/projects/smartmonth
for more info on usage!

Copyright (c) 2009 (Derek Perez | www.derekperez.com), released under the MIT license

Something went wrong with that request. Please try again.