parse time parameters in proper time zone
This commit is contained in:
parent
7f0d8644f8
commit
48daaf51f9
@ -290,11 +290,12 @@ class ApplicationController < ActionController::Base
|
||||
# allow more past data if necessary
|
||||
get_old_data = (params[:results].present? || params[:start].present? || params[:days].present?) ? true : false
|
||||
|
||||
# set default start date
|
||||
start_date = (get_old_data) ? Time.parse('2010-01-01') : (Time.now - 1.day)
|
||||
end_date = Time.now
|
||||
start_date = (Time.now - params[:days].to_i.days) if params[:days]
|
||||
start_date = DateTime.parse(params[:start]) if params[:start]
|
||||
end_date = DateTime.parse(params[:end]) if params[:end]
|
||||
start_date = ActiveSupport::TimeZone[Time.zone.name].parse(params[:start]) if params[:start]
|
||||
end_date = ActiveSupport::TimeZone[Time.zone.name].parse(params[:end]) if params[:end]
|
||||
date_range = (start_date..end_date)
|
||||
# only get a maximum of 30 days worth of data
|
||||
date_range = (end_date - 30.days..end_date) if ((end_date - start_date) > 30.days and !get_old_data)
|
||||
|
@ -269,7 +269,7 @@ class ChannelsController < ApplicationController
|
||||
# try to get created_at datetime if appropriate
|
||||
if params[:created_at].present?
|
||||
begin
|
||||
feed.created_at = DateTime.parse(params[:created_at])
|
||||
feed.created_at = ActiveSupport::TimeZone[Time.zone.name].parse(params[:created_at])
|
||||
# if invalid datetime, don't do anything--rails will set created_at
|
||||
rescue
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user