Skip to content

Instantly share code, notes, and snippets.

@jamestyack
Created January 30, 2015 05:26
Show Gist options
  • Save jamestyack/8dee2a8ea193e184cd02 to your computer and use it in GitHub Desktop.
Save jamestyack/8dee2a8ea193e184cd02 to your computer and use it in GitHub Desktop.
Ruby moving back through dates a month at a time
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