Skip to content

Instantly share code, notes, and snippets.

@ayosec
Created October 24, 2010 18:27
Show Gist options
  • Save ayosec/643801 to your computer and use it in GitHub Desktop.
Save ayosec/643801 to your computer and use it in GitHub Desktop.
#layout
.calendar
- current_date = Date.new(@current_year, 1, 1)
- while current_date.year == @current_year
- if current_date.day == 1
%table.month
%thead
%tr.month-name
%th{:colspan => 7}
= t("date.month_names")[current_date.month]
%tr.day-names
- t("date.abbr_day_names").rotate.each do |day_name|
%th
= day_name
%tbody
- current_month = current_date.month
- while current_date.month == current_month
- wday_based_on_monday = current_date.wday == 0 ? 7 : current_date.wday
%tr.week
- if wday_based_on_monday > 1
%td{:colspan => wday_based_on_monday - 1}
= " "
- while current_date.month == current_month
%td.day{:class => "wday-#{wday_based_on_monday}", :data => {:date => current_date.to_s } }
= current_date.day
- current_date = current_date + 1
- break if current_date.wday == 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment