Skip to content

Instantly share code, notes, and snippets.

# Tasks can fall through the gaps when matching on '='
# e.g. for a task where due_at = 2009-09-16 23:00:00, and where Time.now = 2009-09-16,
# it would not match due_today or due_tomorrow, hence would not appear in Fat Free.
named_scope :due_today, lambda { { :conditions => [ "due_at = ?", Time.zone.now.midnight.utc ], :order => "id DESC" } }
named_scope :due_tomorrow, lambda { { :conditions => [ "due_at = ?", Time.zone.now.midnight.tomorrow.utc ], :order => "id DESC" } }
# By specifying a range of dates, tasks would always match with one of the bucket dates.
named_scope :due_today, lambda {
{ :conditions => [ "due_at >= ? AND due_at < ?", Time.zone.now.midnight.utc, Time.zone.now.midnight.tomorrow.utc ], :order => "id DESC" }
}