Skip to content

Commit

Permalink
fix #584 where the date at the top did not use the users timezone, bu…
Browse files Browse the repository at this point in the history
…t the servers timezone

also remove confusing user_time helper
  • Loading branch information
lrbalt committed Apr 7, 2009
1 parent 183523f commit dd5b479
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 14 deletions.
6 changes: 1 addition & 5 deletions app/helpers/application_helper.rb
Expand Up @@ -2,10 +2,6 @@
# application.
module ApplicationHelper

def user_time
Time.zone.now
end

# Replicates the link_to method but also checks request.request_uri to find
# current page. If that matches the url, the link is marked id = "current"
#
Expand All @@ -24,7 +20,7 @@ def navigation_link(name, options = {}, html_options = nil, *parameters_for_meth
end

def days_from_today(date)
date.in_time_zone.to_date - user_time.to_date
date.in_time_zone.to_date - current_user.time.to_date
end

# Check due date in comparison to today's date Flag up date appropriately with
Expand Down
6 changes: 3 additions & 3 deletions app/helpers/todos_helper.rb
Expand Up @@ -161,11 +161,11 @@ def project_and_context_links(parent_container_type, opts = {})
def staleness_class(item)
if item.due || item.completed?
return ""
elsif item.created_at < user_time - (prefs.staleness_starts * 3).days
elsif item.created_at < current_user.time - (prefs.staleness_starts * 3).days
return " stale_l3"
elsif item.created_at < user_time - (prefs.staleness_starts * 2).days
elsif item.created_at < current_user.time - (prefs.staleness_starts * 2).days
return " stale_l2"
elsif item.created_at < user_time - (prefs.staleness_starts).days
elsif item.created_at < current_user.time - (prefs.staleness_starts).days
return " stale_l1"
else
return ""
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/mobile.m.erb
Expand Up @@ -14,7 +14,7 @@
<% if !(@new_mobile || @edit_mobile)
if !@prefs.nil? -%>
<h1><span class="count"><%= @down_count %></span> <%=
user_time.strftime(@prefs.title_date_format) -%></h1>
current_user.time.strftime(@prefs.title_date_format) -%></h1>
<div class="nav">
<%= (link_to("0-New action", formatted_new_todo_path(:m, new_todo_params))+" | ") unless @new_mobile -%>
<%= (link_to("1-Home", formatted_todos_path(:m))+" | ") unless @home -%>
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/standard.html.erb
Expand Up @@ -31,7 +31,7 @@
<% if @count -%>
<span id="badge_count" class="badge"><%= @count %></span>
<% end -%>
<%= user_time.strftime(@prefs.title_date_format) %>
<%= current_user.time.strftime(@prefs.title_date_format) %>
</h1>
</div>
<div id="minilinks">
Expand Down
6 changes: 3 additions & 3 deletions app/views/preferences/index.html.erb
Expand Up @@ -5,9 +5,9 @@
<ul id="prefs">
<li>First name: <span class="highlight"><%= current_user.first_name %></span></li>
<li>Last name: <span class="highlight"><%= current_user.last_name %></span></li>
<li>Date format: <span class="highlight"><%= prefs.date_format %></span> Your current date: <%= format_date(user_time) %></li>
<li>Title date format: <span class="highlight"><%= prefs.title_date_format %></span> Your current title date: <%= user_time.strftime(prefs.title_date_format) %></li>
<li>Time zone: <span class="highlight"><%= prefs.time_zone %></span> Your current time: <%= user_time.strftime('%I:%M %p') %></li>
<li>Date format: <span class="highlight"><%= prefs.date_format %></span> Your current date: <%= format_date(current_user.time) %></li>
<li>Title date format: <span class="highlight"><%= prefs.title_date_format %></span> Your current title date: <%= current_user.time.strftime(prefs.title_date_format) %></li>
<li>Time zone: <span class="highlight"><%= prefs.time_zone %></span> Your current time: <%= current_user.time.strftime('%I:%M %p') %></li>
<li>Week starts on: <span class="highlight"><%= Preference.day_number_to_name_map[prefs.week_starts] %></span></li>
<li>Show the last <span class="highlight"><%= prefs.show_number_completed %></span> completed items</li>
<li>Show completed projects in sidebar: <span class="highlight"><%= prefs.show_completed_projects_in_sidebar %></span></li>
Expand Down
2 changes: 1 addition & 1 deletion app/views/todos/_edit_mobile.rhtml
Expand Up @@ -3,7 +3,7 @@
<span class="errors">
<%= error_messages_for("todo") %>
</span>
<% this_year = user_time.to_date.strftime("%Y").to_i
<% this_year = current_user.time.to_date.strftime("%Y").to_i
if parent_container_type == 'show_mobile' -%>
<p><label for="todo_done">Done?</label>&nbsp;<%= check_box_tag("done", 1, @todo && @todo.completed?, "tabindex" => 1) %></p>
<% end -%>
Expand Down

0 comments on commit dd5b479

Please sign in to comment.