Last active
March 16, 2016 23:52
-
-
Save jonasporto/26108e71d8f4c253f5fd to your computer and use it in GitHub Desktop.
Working with date ruby
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
http://stackoverflow.com/questions/8511919/how-to-scope-last-week-by-date-object | |
https://nandovieira.com.br/trabalhando-com-datas-no-ruby-on-rails | |
https://nandovieira.com.br/formatando-datas-no-ruby-on-rails | |
Date.today.beginning_of_month | |
scope :completed_at_last_week, -> { | |
where( | |
completed_at: 1.week.ago.beginning_of_week..1.week.ago.end_of_week | |
) | |
} | |
scope :completed_at_last_month, -> { | |
where( | |
completed_at: 1.month.ago.beginning_of_month..1.month.ago.end_of_month | |
) | |
} | |
completed_at: Date.today.beginning_of_month..Date.today.end_of_month | |
Date.today.beginning_of_week(start_day = :sunday) | |
Date.today.end_of_week | |
Date.today.end_of_week(end_day = :saturday) | |
Date.today.end_of_week(end_day = :sunday) | |
Date.today.end_of_week(:sunday) |
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
dsfdsfdsfdsfds |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment