Created
January 18, 2009 22:45
-
-
Save mrjjwright/48796 to your computer and use it in GitHub Desktop.
This file contains 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
named_scope :since, lambda { |dateterm| | |
day = Chronic.parse(dateterm, :context => :past) | |
day = Time.parse(dateterm) if day.nil? | |
raise "Could not parse date" if day.nil? | |
{ :conditions => ['created_at >= ?', Time.zone.parse(day.to_date.to_s).utc], :order => 'created_at asc' } | |
} | |
named_scope :on, lambda { |dateterm| | |
day = Chronic.parse(dateterm, :context => :past) | |
day = Time.parse(dateterm) if day.nil? | |
raise "Could not parse date" if day.nil? | |
day = Time.zone.parse(day.to_date.to_s).utc | |
{ :conditions => ['created_at >= ? and created_at < ?', day, day + 86400], :order => 'created_at desc' } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment