summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/helpers/application_helper.rb8
-rw-r--r--app/models/project.rb2
-rw-r--r--app/models/user.rb8
-rw-r--r--app/views/my/account.rhtml1
4 files changed, 17 insertions, 2 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 215945423..80694e744 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -79,9 +79,15 @@ module ApplicationHelper
def format_time(time, include_date = true)
return nil unless time
time = time.to_time if time.is_a?(String)
+ zone = User.current.time_zone
+ if time.utc?
+ local = zone ? zone.adjust(time) : time.getlocal
+ else
+ local = zone ? zone.adjust(time.getutc) : time
+ end
@date_format ||= (Setting.date_format.blank? || Setting.date_format.size < 2 ? l(:general_fmt_date) : Setting.date_format)
@time_format ||= (Setting.time_format.blank? ? l(:general_fmt_time) : Setting.time_format)
- include_date ? time.strftime("#{@date_format} #{@time_format}") : time.strftime(@time_format)
+ include_date ? local.strftime("#{@date_format} #{@time_format}") : local.strftime(@time_format)
end
def authoring(created, author)
diff --git a/app/models/project.rb b/app/models/project.rb
index 1fbab2e4d..afaa049c6 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -150,7 +150,7 @@ class Project < ActiveRecord::Base
end
def <=>(project)
- name <=> project.name
+ name.downcase <=> project.name.downcase
end
def allows_to?(action)
diff --git a/app/models/user.rb b/app/models/user.rb
index 9c8d1d9a3..2543bed19 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -130,6 +130,10 @@ class User < ActiveRecord::Base
self.preference ||= UserPreference.new(:user => self)
end
+ def time_zone
+ self.pref.time_zone.nil? ? nil : TimeZone[self.pref.time_zone]
+ end
+
# Return user's RSS key (a 40 chars long string), used to access feeds
def rss_key
token = self.rss_token || Token.create(:user => self, :action => 'feeds')
@@ -231,6 +235,10 @@ class AnonymousUser < User
false
end
+ def time_zone
+ nil
+ end
+
# Anonymous user has no RSS key
def rss_key
nil
diff --git a/app/views/my/account.rhtml b/app/views/my/account.rhtml
index 11bba9c8d..e64051771 100644
--- a/app/views/my/account.rhtml
+++ b/app/views/my/account.rhtml
@@ -14,6 +14,7 @@
<p><%= f.select :language, lang_options_for_select %></p>
<% fields_for :pref, @user.pref, :builder => TabularFormBuilder, :lang => current_language do |pref_fields| %>
+<p><%= pref_fields.select :time_zone, TimeZone.all.collect {|z| [ z.to_s, z.name ]}, :include_blank => true %></p>
<p><%= pref_fields.check_box :hide_mail %></p>
<% end %>
</div>