-
-
Save michaeldv/188101 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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" } | |
} | |
named_scope :due_tomorrow, lambda { | |
{ :conditions => [ "due_at >= ? AND due_at < ?", Time.zone.now.midnight.tomorrow.utc, Time.zone.now.midnight.tomorrow.utc + 1.day ], :order => "id DESC" } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment