Topic: cool and simple calendar [SOLVED]

I needed to use a calendar that allow me access to the date to add my events so i got this nice little calendar and it seems to be working properly but i saw that the date is not quite right its telling me that the 11-12-12 is on a Sunday and not on a Tuesday


can someone test it and see what they can find,



- dif = params[:dif].to_i
- url = request.url.split('?').first
- today = Date.today  + dif.month
- year = today.try(:strftime, '%y').to_i
- month = today.try(:strftime, '%m').to_i
%table{:cellpading => "10", :cellspacing => "10", :id => "‘calendar’", :width => "100%", :border =>1}
  %tr
    %th{:colspan => "7"}
      %h1
        %a{:href => url + "?dif=" + (dif - 1).to_s } -
        = today.try(:strftime, '%B')
        = today.try(:strftime, '%Y')
        %a{:href => url +"?dif=" + (dif + 1).to_s}+
  %tr
    %th Sunday
    %th Monday
    %th Tuesday
    %th Wednesday
    %th Thursday
    %th Friday
    %th Saturday
  %tr
    - @beginning_of_month = Date.civil(year, month, 1)
    - @end_of_month = Date.civil(year, month, -1)
    - (@beginning_of_month..@end_of_month).each do |d|
      - if d == @beginning_of_month
        - d.wday.times do
          %td{:class => "‘offset’"}
      - if d.wday == 0
        %tr
      %td
        = d.day

Last edited by moiseszaragoza (2012-12-11 16:12:39)

Re: cool and simple calendar [SOLVED]

What you need to do is change the lowercase y with a capital Y so it reads 2012 instead of 12

- year = today.try(:strftime, '%y').to_i

with

- year = today.try(:strftime, '%Y').to_i