Skip to content

Instantly share code, notes, and snippets.

@mhemesath
Created July 23, 2013 02:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhemesath/6059490 to your computer and use it in GitHub Desktop.
Save mhemesath/6059490 to your computer and use it in GitHub Desktop.
<% start_date = date.beginning_of_month.beginning_of_week - 1.day %>
<% end_of_month = date.end_of_month.end_of_week %>
<% weeks = (start_date...end_of_month).each_slice(7).to_a %>
<table>
<thead>
<% (0..6).each do |i| %>
<th><%= (start_date + i.days).strftime('%a') %></th>
<% end %>
</thead>
<tbody>
<% weeks.each do |week| %>
<tr>
<% week.each do |day| %>
<td>
<div><%= day.strftime("%-d") %></div>
</td>
<% end %>
</tr>
<% end %>
</tbody>
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment