Skip to content

Instantly share code, notes, and snippets.

@danielvlopes
Last active August 29, 2015 14:17
Show Gist options
  • Save danielvlopes/572d3d741b8124370e87 to your computer and use it in GitHub Desktop.
Save danielvlopes/572d3d741b8124370e87 to your computer and use it in GitHub Desktop.
module ApplicationHelper
def calendar(date = Date.today)
d1 = date.beginning_of_month
d2 = date.end_of_month
month = []
current = d1.beginning_of_week(:sunday)
while current <= d2
week = []
(0..6).each do |wd|
week << (current + wd)
end
current = current + 7
month << week
end
month
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment