Skip to content

Commit

Permalink
If Time's zone is nil, don't crash.
Browse files Browse the repository at this point in the history
  • Loading branch information
johndouthat authored and topfunky committed Nov 2, 2009
1 parent 8d1977e commit 01f26ae
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/calendar_helper.rb
Expand Up @@ -139,8 +139,9 @@ def calendar(options = {}, &block)
cell_text ||= cur.mday
cell_attrs ||= {}
cell_attrs[:class] ||= options[:day_class]
cell_attrs[:class] += " weekendDay" if [0, 6].include?(cur.wday)
cell_attrs[:class] += " today" if (cur == (Time.respond_to?(:zone) ? Time.zone.now.to_date : Date.today)) and options[:show_today]
cell_attrs[:class] += " weekendDay" if [0, 6].include?(cur.wday)
today = (Time.respond_to?(:zone) && !(zone = Time.zone).nil? ? zone.now.to_date : Date.today)
cell_attrs[:class] += " today" if (cur == today) and options[:show_today]
cell_attrs = cell_attrs.map {|k, v| %(#{k}="#{v}") }.join(" ")
cal << "<td #{cell_attrs}>#{cell_text}</td>"
cal << "</tr><tr>" if cur.wday == last_weekday
Expand Down

0 comments on commit 01f26ae

Please sign in to comment.