Navigation Menu

Skip to content

Commit

Permalink
Use aliased attribute methods in EventCalendar
Browse files Browse the repository at this point in the history
In 'adjust_all_day_dates', use the aliased attribute methods 'start_at'
and 'end_at' rather than 'self[:start_at]' and 'self[:end_at]' just in
case someone's using all-day events with custom models using attributes
other than 'start_at' and/or 'end_at'.
  • Loading branch information
Bryan T. Richardson authored and jeffschuil committed Dec 29, 2010
1 parent aed248c commit 9d5a055
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/event_calendar.rb
Expand Up @@ -175,12 +175,13 @@ def clip_range(start_d, end_d)
end

def adjust_all_day_dates
if self[:all_day]
self[:start_at] = self[:start_at].beginning_of_day
if self[:end_at]
self[:end_at] = self[:end_at].beginning_of_day + 1.day - 1.second
if self.all_day
self.start_at = self.start_at.beginning_of_day

if self.end_at
self.end_at = self.end_at.beginning_of_day + 1.day - 1.second
else
self[:end_at] = self[:start_at].beginning_of_day + 1.day - 1.second
self.end_at = self.start_at + 1.day - 1.second
end
end
end
Expand Down

0 comments on commit 9d5a055

Please sign in to comment.