Skip to content

Instantly share code, notes, and snippets.

@perezd
Created February 27, 2009 08:35
Show Gist options
  • Save perezd/71362 to your computer and use it in GitHub Desktop.
Save perezd/71362 to your computer and use it in GitHub Desktop.
require 'smart_month'
# an example of the simple to use syntax
Time.now.month.first_and_third_friday #=> array of corresponding date objects
# access month as an array
Month[1] #=> Jan Object
Month[12] #=> Dec Object
# access month as hash
Month[:december] #=> Dec Object
Month[:march] #=> Mar Object
# access month "dynamically"
Month.december #=> Dec Object
# access every tuesday in december 2010
Month.december(2010).every_tuesday #=> array of corresponding date objects
# access every tuesday and friday in march
Month.march.every_tuesday_and_friday #=> array of corresponding date objects
Month.march.every!(:tuesday,:friday) #=> hash of corresponding date objects, keyed by the day they are associated with
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment