Replace User#time with UserTime#time

This commit is contained in:
Matt Rogers 2013-07-30 16:18:06 -05:00
parent 8512e8db3b
commit 96777c2e3a
13 changed files with 44 additions and 27 deletions

View file

@ -29,7 +29,7 @@ module ApplicationHelper
end
def days_from_today(date)
(date.in_time_zone.to_date - current_user.time.to_date).to_i
(date.in_time_zone.to_date - UserTime.new(current_user).date).to_i
end
# Check due date in comparison to today's date Flag up date appropriately with

View file

@ -99,9 +99,10 @@ class Project < ActiveRecord::Base
end
end
def needs_review?(current_user)
def needs_review?(user)
current_time = UserTime.new(user).time
return active? && ( last_reviewed.nil? ||
(last_reviewed < current_user.time - current_user.prefs.review_period.days))
(last_reviewed < current_time - user.prefs.review_period.days))
end
def blocked?

View file

@ -159,10 +159,6 @@ class User < ActiveRecord::Base
save!
end
def time
Time.now.in_time_zone(prefs.time_zone)
end
def date
UserTime.new(self).midnight(Time.now)
end

View file

@ -30,7 +30,7 @@
<div id="recurring_timespan">
<br/>
<label for="recurring_todo[start_from]"><%= t('todos.recurrence.starts_on') %>:</label><%=
text_field(:recurring_todo, :start_from, "value" => format_date(current_user.time), "size" => 12, "class" => "Date", "autocomplete" => "off") %><br/>
text_field(:recurring_todo, :start_from, "value" => format_date(UserTime.new(current_user).time), "size" => 12, "class" => "Date", "autocomplete" => "off") %><br/>
<br/>
<label for="recurring_todo[ends_on]"><%= t('todos.recurrence.ends_on') %>:</label><br/>
<%= radio_button_tag('recurring_todo[ends_on]', 'no_end_date', true)%> <%= t('todos.recurrence.no_end_date') %><br/>

View file

@ -3,7 +3,7 @@
<span class="errors">
<%= get_list_of_error_messages_for(@todo) if @todo %>
</span>
<% this_year = current_user.time.to_date.strftime("%Y").to_i -%>
<% this_year = UserTime.new(current_user).date.strftime("%Y").to_i -%>
<h2><label for="todo_description"><%= t('common.description') %></label></h2>
<%= text_field( "todo", "description", "tabindex" => 1, "maxlength" => 100, "size" => 50) %>
<h2><label for="tag_list"><%= t('todos.tags') %></label></h2>