Created
January 30, 2015 05:26
-
-
Save jamestyack/8dee2a8ea193e184cd02 to your computer and use it in GitHub Desktop.
Ruby moving back through dates a month at a time
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
def prev_month_list_based_on_1st_current_month(prev_month_range) | |
today = Date.today | |
beg_of_current_month = today - today.day + 1 | |
prev_month_range.to_a.map { | prev_month_number | beg_of_current_month.prev_month(prev_month_number) } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment