propublica/pixel-pong — Issue #1: Front page and search should reflect local time
Author: ghing
Created: 2011-12-13 03:12:27+00:00
State: open

The stats are stored in the database with a created_at attribute set to UTC. However, the front page and search options use local time. So, stats logged at 9PM Eastern Time won't appear on the front page because they're logged in the database with a created_at time set to the next day.

I'm not that familiar with RoR, but I think converting the current local time or the times specified in the form to UTC before retrieving the stats fixes this issue:

```
diff --git a/app/controllers/application_controller.rb b/app/controllers/applica
index 3cbab16..e81b591 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -6,14 +6,14 @@ class ApplicationController < ActionController::Base
before_filter :timeframe

def timeframe
- @today = Date.today.to_time
+ @today = Date.today.to_time.utc
@conditions = ["created_at > :start_date and created_at <= :end_date", {
:start_date => @today,
:end_date => @today + 1.day
}]
@conditions = ["created_at > :start_date and created_at <= :end_date", {
- :start_date => Time.parse(params[:start_date]).to_date.to_time,
- :end_date => Time.parse(params[:end_date]).to_date.to_time + 1.day
+ :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
}] if params[:start_date] && params[:end_date]
end
# Scrub sensitive parameters from your log
```