Permalink
Browse files

Use application timezone (not server timezone) for determining defaul…

…t time frame.

Also use beginning_of_day and end_of_day methods for setting time frame limits.
  • Loading branch information...
1 parent 740137f commit 4789a4e1d69a8c7350aa9a15122019cf5d1a71ec @ghing ghing committed Dec 24, 2011
Showing with 5 additions and 5 deletions.
  1. +5 −5 app/controllers/application_controller.rb
View
10 app/controllers/application_controller.rb
@@ -6,14 +6,14 @@ class ApplicationController < ActionController::Base
before_filter :timeframe
def timeframe
- @today = Date.today.to_time.utc
+ @today = Time.zone.today
@conditions = ["created_at > :start_date and created_at <= :end_date", {
- :start_date => @today,
- :end_date => @today + 1.day
+ :start_date => @today.beginning_of_day.utc,
+ :end_date => @today.end_of_day.utc
}]
@conditions = ["created_at > :start_date and created_at <= :end_date", {
- :start_date => Time.parse(params[:start_date]).to_date.to_time.utc,
- :end_date => Time.parse(params[:end_date]).to_date.to_time.utc + 1.day
+ :start_date => Time.parse(params[:start_date]).to_date.beginning_of_day.utc,
+ :end_date => Time.parse(params[:end_date]).to_date.end_of_day.utc
}] if params[:start_date] && params[:end_date]
end
# Scrub sensitive parameters from your log

0 comments on commit 4789a4e

Please sign in to comment.