From 622291d98d7ad586e22a4637d0e9670ae532ddac Mon Sep 17 00:00:00 2001 From: Dan Rice Date: Thu, 12 Jun 2014 21:24:31 -0400 Subject: [PATCH] Purge UserTime from app/* --- app/helpers/application_helper.rb | 2 +- app/models/preference.rb | 4 ++-- app/models/project.rb | 3 +-- app/models/todo.rb | 2 +- app/models/user.rb | 4 ++-- app/views/recurring_todos/_recurring_todo_form.html.erb | 2 +- app/views/todos/_edit_form.m.erb | 5 ++--- 7 files changed, 10 insertions(+), 12 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index f4238999..07c95e87 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -29,7 +29,7 @@ module ApplicationHelper end def days_from_today(date) - (date.in_time_zone.to_date - UserTime.new(current_user).date).to_i + (date.in_time_zone.to_date - Date.current).to_i end # Check due date in comparison to today's date Flag up date appropriately with diff --git a/app/models/preference.rb b/app/models/preference.rb index e0150cd8..c4ccb5f1 100644 --- a/app/models/preference.rb +++ b/app/models/preference.rb @@ -15,13 +15,13 @@ class Preference < ActiveRecord::Base date = nil if s.is_a?(Time) - date = s.in_time_zone(time_zone).to_date + date = s.to_date elsif s.is_a?(String) date = Date.strptime(s, date_format) else raise ArgumentError.new("Bad argument type:#{s.class}") end - UserTime.new(user).midnight(date) + date.in_time_zone(time_zone).beginning_of_day end end diff --git a/app/models/project.rb b/app/models/project.rb index c59f8bd9..913b8127 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -101,9 +101,8 @@ class Project < ActiveRecord::Base end def needs_review?(user) - current_time = UserTime.new(user).time return active? && ( last_reviewed.nil? || - (last_reviewed < current_time - user.prefs.review_period.days)) + (last_reviewed < Time.current - user.prefs.review_period.days)) end def blocked? diff --git a/app/models/todo.rb b/app/models/todo.rb index d91d8ee1..f9c1fa47 100644 --- a/app/models/todo.rb +++ b/app/models/todo.rb @@ -264,7 +264,7 @@ class Todo < ActiveRecord::Base activate else # parse Date objects into the proper timezone - date = UserTime.new(user).midnight(date) if (date.is_a? Date) + date = date.in_time_zone.beginning_of_day if (date.is_a? Date) # show_from needs to be set before state_change because of "bug" in aasm. # If show_from is not set, the todo will not validate and thus aasm will not save diff --git a/app/models/user.rb b/app/models/user.rb index 4fb1ca29..f93ccfac 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -90,7 +90,7 @@ class User < ActiveRecord::Base order('show_from ASC, todos.created_at DESC')}, :class_name => 'Todo') do def find_and_activate_ready - where('show_from <= ?', Time.zone.now).collect { |t| t.activate! } + where('show_from <= ?', Time.current).collect { |t| t.activate! } end end @@ -160,7 +160,7 @@ class User < ActiveRecord::Base end def date - UserTime.new(self).midnight(Time.now) + Date.current end def generate_token diff --git a/app/views/recurring_todos/_recurring_todo_form.html.erb b/app/views/recurring_todos/_recurring_todo_form.html.erb index 2ad9ac63..124caf96 100644 --- a/app/views/recurring_todos/_recurring_todo_form.html.erb +++ b/app/views/recurring_todos/_recurring_todo_form.html.erb @@ -30,7 +30,7 @@

<%= - text_field(:recurring_todo, :start_from, "value" => format_date(UserTime.new(current_user).time), "size" => 12, "class" => "Date", "autocomplete" => "off") %>
+ text_field(:recurring_todo, :start_from, "value" => format_date(Date.current), "size" => 12, "class" => "Date", "autocomplete" => "off") %>


<%= radio_button_tag('recurring_todo[ends_on]', 'no_end_date', true)%> <%= t('todos.recurrence.no_end_date') %>
diff --git a/app/views/todos/_edit_form.m.erb b/app/views/todos/_edit_form.m.erb index c7fb5a59..dd08b1e9 100644 --- a/app/views/todos/_edit_form.m.erb +++ b/app/views/todos/_edit_form.m.erb @@ -3,7 +3,6 @@ <%= get_list_of_error_messages_for(@todo) if @todo %> -<% this_year = UserTime.new(current_user).date.strftime("%Y").to_i -%>

<%= text_field( "todo", "description", "tabindex" => 1, "maxlength" => 100, "size" => 50) %>

@@ -32,7 +31,7 @@ end %> <%= text_area( "todo", "notes", "cols" => 40, "rows" => 3, "tabindex" => 5) %>

<%= date_select("todo", "due", {:order => [:day, :month, :year], - :start_year => this_year, :include_blank => '--'}, :tabindex => 6) %> + :start_year => Date.current.year, :include_blank => '--'}, :tabindex => 6) %>

<%= date_select("todo", "show_from", {:order => [:day, :month, :year], - :start_year => this_year, :include_blank => true}, :tabindex => 7) %> + :start_year => Date.current.year, :include_blank => true}, :tabindex => 7) %>