Files
danbooru/app/helpers/popular_posts_helper.rb
evazion e8590afa6d popular posts: fix date range handling.
* Fix the next button for the weekly timescale to jump to the next week,
  not the next day.
* Show the start and end dates for the weekly timescale.
* Use `Time.zone.today` instead of `Date.today` to respect the user's
  timezone setting.
2020-02-23 17:26:08 -06:00

24 lines
391 B
Ruby

module PopularPostsHelper
def next_date_for_scale(date, scale)
case scale
when "day"
date + 1.day
when "week"
date + 1.week
when "month"
1.month.since(date)
end
end
def prev_date_for_scale(date, scale)
case scale
when "day"
date - 1.day
when "week"
date - 7.days
when "month"
1.month.ago(date)
end
end
end