Skip to content

Instantly share code, notes, and snippets.

@ptb
Created May 19, 2013 19:39
Show Gist options
  • Select an option

  • Save ptb/5608717 to your computer and use it in GitHub Desktop.

Select an option

Save ptb/5608717 to your computer and use it in GitHub Desktop.
- require 'date'
- require 'active_support'
- @d = Date.today
- @week1 = @d.beginning_of_month.beginning_of_week(:sunday)
- @weekn = @d.end_of_month.end_of_week(:sunday)
- @weeks = (@week1..@weekn).to_a.in_groups_of(7)
- content_for :head do
link[href='/test/table/calendar2.css' rel='stylesheet']/
table.cal.vevent[aria-labelledby='month' itemscope itemtype='http://schema.org/Event' role='presentation']
caption#month
div: a[href="/availability?during=#{@d.prev_month.strftime('%b-%Y')}" rel='prev' role='button'] Previous Month
div: time[datetime="#{@d.strftime('%Y-%m')}"] = @d.strftime('%B %Y')
div: a[href="/availability?during=#{@d.next_month.strftime('%b-%Y')}" rel='next' role='button'] Next Month
thead
tr[aria-hidden='true']
- Date::DAYNAMES.each do |day|
th[scope='col']
abbr[title="#{day}"] = day[0..2]
tbody
- @weeks.map do |week|
tr
- week.map do |day|
td
ruby:
c = []
c << 'prev' if day.month < @d.month
c << 'next' if day.month > @d.month
c << 'today' if day == Date.today
today = day == Date.today ? 'Today: ' : nil
ad = day < Date.today
as = rand(20) == 10 ? true : false
time[class=c datetime="#{day.strftime('%Y-%m-%d')}"]
a[aria-disabled="#{ad}" aria-selected="#{as}" href="/availability?#{c.include?('prev') ? 'during=' + day.strftime('%b-%Y') + '&' : nil}#{c.include?('next') ? 'during=' + day.strftime('%b-%Y') + '&' : nil}starting=#{day.strftime('%Y-%m-%d')}" role='button']
span[aria-hidden='false'] #{today}#{day.strftime('%A, %B ')}
= day.day
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment