@@ -43,7 +43,7 class ActivitiesController < ApplicationController | |||
|
43 | 43 | if events.empty? || stale?(:etag => [@activity.scope, @date_to, @date_from, @with_subprojects, @author, events.first, User.current, current_language]) |
|
44 | 44 | respond_to do |format| |
|
45 | 45 | format.html { |
|
46 |
@events_by_day = events.group_by( |
|
|
46 | @events_by_day = events.group_by {|event| User.current.time_to_date(event.event_datetime)} | |
|
47 | 47 | render :layout => false if request.xhr? |
|
48 | 48 | } |
|
49 | 49 | format.atom { |
@@ -178,7 +178,7 module ApplicationHelper | |||
|
178 | 178 | end |
|
179 | 179 | |
|
180 | 180 | def format_activity_day(date) |
|
181 |
date == |
|
|
181 | date == User.current.today ? l(:label_today).titleize : format_date(date) | |
|
182 | 182 | end |
|
183 | 183 | |
|
184 | 184 | def format_activity_description(text) |
@@ -352,7 +352,7 module ApplicationHelper | |||
|
352 | 352 | def time_tag(time) |
|
353 | 353 | text = distance_of_time_in_words(Time.now, time) |
|
354 | 354 | if @project |
|
355 |
link_to(text, {:controller => 'activities', :action => 'index', :id => @project, :from => time |
|
|
355 | link_to(text, {:controller => 'activities', :action => 'index', :id => @project, :from => User.current.time_to_date(time)}, :title => format_time(time)) | |
|
356 | 356 | else |
|
357 | 357 | content_tag('acronym', text, :title => format_time(time)) |
|
358 | 358 | end |
@@ -848,12 +848,18 class Query < ActiveRecord::Base | |||
|
848 | 848 | s = [] |
|
849 | 849 | if from |
|
850 | 850 | from_yesterday = from - 1 |
|
851 |
from_yesterday_ |
|
|
852 | s << ("#{table}.#{field} > '%s'" % [connection.quoted_date(from_yesterday_utc.end_of_day)]) | |
|
851 | from_yesterday_time = Time.local(from_yesterday.year, from_yesterday.month, from_yesterday.day) | |
|
852 | if self.class.default_timezone == :utc | |
|
853 | from_yesterday_time = from_yesterday_time.utc | |
|
854 | end | |
|
855 | s << ("#{table}.#{field} > '%s'" % [connection.quoted_date(from_yesterday_time.end_of_day)]) | |
|
853 | 856 | end |
|
854 | 857 | if to |
|
855 |
to_ |
|
|
856 | s << ("#{table}.#{field} <= '%s'" % [connection.quoted_date(to_utc.end_of_day)]) | |
|
858 | to_time = Time.local(to.year, to.month, to.day) | |
|
859 | if self.class.default_timezone == :utc | |
|
860 | to_time = to_time.utc | |
|
861 | end | |
|
862 | s << ("#{table}.#{field} <= '%s'" % [connection.quoted_date(to_time.end_of_day)]) | |
|
857 | 863 | end |
|
858 | 864 | s.join(' AND ') |
|
859 | 865 | end |
@@ -370,6 +370,15 class User < Principal | |||
|
370 | 370 | end |
|
371 | 371 | end |
|
372 | 372 | |
|
373 | # Returns the day of +time+ according to user's time zone | |
|
374 | def time_to_date(time) | |
|
375 | if time_zone.nil? | |
|
376 | time.to_date | |
|
377 | else | |
|
378 | time.in_time_zone(time_zone).to_date | |
|
379 | end | |
|
380 | end | |
|
381 | ||
|
373 | 382 | def logged? |
|
374 | 383 | true |
|
375 | 384 | end |
@@ -143,7 +143,7 class WikiPage < ActiveRecord::Base | |||
|
143 | 143 | if time = read_attribute(:updated_on) |
|
144 | 144 | # content updated_on was eager loaded with the page |
|
145 | 145 | begin |
|
146 |
@updated_on = |
|
|
146 | @updated_on = (self.class.default_timezone == :utc ? Time.parse(time.to_s).utc : Time.parse(time.to_s).localtime) | |
|
147 | 147 | rescue |
|
148 | 148 | end |
|
149 | 149 | else |
@@ -26,6 +26,7 module RedmineApp | |||
|
26 | 26 | config.active_record.observers = :message_observer, :issue_observer, :journal_observer, :news_observer, :document_observer, :wiki_content_observer, :comment_observer |
|
27 | 27 | |
|
28 | 28 | config.active_record.store_full_sti_class = true |
|
29 | config.active_record.default_timezone = :local | |
|
29 | 30 | |
|
30 | 31 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. |
|
31 | 32 | # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. |
@@ -1,8 +1,8 | |||
|
1 | 1 | --- |
|
2 | 2 | issues_001: |
|
3 |
created_on: <%= 3.days.ago.to_ |
|
|
3 | created_on: <%= 3.days.ago.to_s(:db) %> | |
|
4 | 4 | project_id: 1 |
|
5 |
updated_on: <%= 1.day.ago.to_ |
|
|
5 | updated_on: <%= 1.day.ago.to_s(:db) %> | |
|
6 | 6 | priority_id: 4 |
|
7 | 7 | subject: Can't print recipes |
|
8 | 8 | id: 1 |
@@ -60,9 +60,9 issues_003: | |||
|
60 | 60 | lft: 1 |
|
61 | 61 | rgt: 2 |
|
62 | 62 | issues_004: |
|
63 |
created_on: <%= 5.days.ago.to_ |
|
|
63 | created_on: <%= 5.days.ago.to_s(:db) %> | |
|
64 | 64 | project_id: 2 |
|
65 |
updated_on: <%= 2.days.ago.to_ |
|
|
65 | updated_on: <%= 2.days.ago.to_s(:db) %> | |
|
66 | 66 | priority_id: 4 |
|
67 | 67 | subject: Issue on project 2 |
|
68 | 68 | id: 4 |
@@ -77,9 +77,9 issues_004: | |||
|
77 | 77 | lft: 1 |
|
78 | 78 | rgt: 2 |
|
79 | 79 | issues_005: |
|
80 |
created_on: <%= 5.days.ago.to_ |
|
|
80 | created_on: <%= 5.days.ago.to_s(:db) %> | |
|
81 | 81 | project_id: 3 |
|
82 |
updated_on: <%= 2.days.ago.to_ |
|
|
82 | updated_on: <%= 2.days.ago.to_s(:db) %> | |
|
83 | 83 | priority_id: 4 |
|
84 | 84 | subject: Subproject issue |
|
85 | 85 | id: 5 |
@@ -94,9 +94,9 issues_005: | |||
|
94 | 94 | lft: 1 |
|
95 | 95 | rgt: 2 |
|
96 | 96 | issues_006: |
|
97 |
created_on: <%= 1.minute.ago.to_ |
|
|
97 | created_on: <%= 1.minute.ago.to_s(:db) %> | |
|
98 | 98 | project_id: 5 |
|
99 |
updated_on: <%= 1.minute.ago.to_ |
|
|
99 | updated_on: <%= 1.minute.ago.to_s(:db) %> | |
|
100 | 100 | priority_id: 4 |
|
101 | 101 | subject: Issue of a private subproject |
|
102 | 102 | id: 6 |
@@ -113,9 +113,9 issues_006: | |||
|
113 | 113 | lft: 1 |
|
114 | 114 | rgt: 2 |
|
115 | 115 | issues_007: |
|
116 |
created_on: <%= 10.days.ago.to_ |
|
|
116 | created_on: <%= 10.days.ago.to_s(:db) %> | |
|
117 | 117 | project_id: 1 |
|
118 |
updated_on: <%= 10.days.ago.to_ |
|
|
118 | updated_on: <%= 10.days.ago.to_s(:db) %> | |
|
119 | 119 | priority_id: 5 |
|
120 | 120 | subject: Issue due today |
|
121 | 121 | id: 7 |
@@ -133,9 +133,9 issues_007: | |||
|
133 | 133 | lft: 1 |
|
134 | 134 | rgt: 2 |
|
135 | 135 | issues_008: |
|
136 |
created_on: <%= 10.days.ago.to_ |
|
|
136 | created_on: <%= 10.days.ago.to_s(:db) %> | |
|
137 | 137 | project_id: 1 |
|
138 |
updated_on: <%= 10.days.ago.to_ |
|
|
138 | updated_on: <%= 10.days.ago.to_s(:db) %> | |
|
139 | 139 | priority_id: 5 |
|
140 | 140 | subject: Closed issue |
|
141 | 141 | id: 8 |
@@ -153,9 +153,9 issues_008: | |||
|
153 | 153 | lft: 1 |
|
154 | 154 | rgt: 2 |
|
155 | 155 | issues_009: |
|
156 |
created_on: <%= 1.minute.ago.to_ |
|
|
156 | created_on: <%= 1.minute.ago.to_s(:db) %> | |
|
157 | 157 | project_id: 5 |
|
158 |
updated_on: <%= 1.minute.ago.to_ |
|
|
158 | updated_on: <%= 1.minute.ago.to_s(:db) %> | |
|
159 | 159 | priority_id: 5 |
|
160 | 160 | subject: Blocked Issue |
|
161 | 161 | id: 9 |
@@ -172,9 +172,9 issues_009: | |||
|
172 | 172 | lft: 1 |
|
173 | 173 | rgt: 2 |
|
174 | 174 | issues_010: |
|
175 |
created_on: <%= 1.minute.ago.to_ |
|
|
175 | created_on: <%= 1.minute.ago.to_s(:db) %> | |
|
176 | 176 | project_id: 5 |
|
177 |
updated_on: <%= 1.minute.ago.to_ |
|
|
177 | updated_on: <%= 1.minute.ago.to_s(:db) %> | |
|
178 | 178 | priority_id: 5 |
|
179 | 179 | subject: Issue Doing the Blocking |
|
180 | 180 | id: 10 |
@@ -191,9 +191,9 issues_010: | |||
|
191 | 191 | lft: 1 |
|
192 | 192 | rgt: 2 |
|
193 | 193 | issues_011: |
|
194 |
created_on: <%= 3.days.ago.to_ |
|
|
194 | created_on: <%= 3.days.ago.to_s(:db) %> | |
|
195 | 195 | project_id: 1 |
|
196 |
updated_on: <%= 1.day.ago.to_ |
|
|
196 | updated_on: <%= 1.day.ago.to_s(:db) %> | |
|
197 | 197 | priority_id: 5 |
|
198 | 198 | subject: Closed issue on a closed version |
|
199 | 199 | id: 11 |
@@ -210,9 +210,9 issues_011: | |||
|
210 | 210 | lft: 1 |
|
211 | 211 | rgt: 2 |
|
212 | 212 | issues_012: |
|
213 |
created_on: <%= 3.days.ago.to_ |
|
|
213 | created_on: <%= 3.days.ago.to_s(:db) %> | |
|
214 | 214 | project_id: 1 |
|
215 |
updated_on: <%= 1.day.ago.to_ |
|
|
215 | updated_on: <%= 1.day.ago.to_s(:db) %> | |
|
216 | 216 | priority_id: 5 |
|
217 | 217 | subject: Closed issue on a locked version |
|
218 | 218 | id: 12 |
@@ -229,9 +229,9 issues_012: | |||
|
229 | 229 | lft: 1 |
|
230 | 230 | rgt: 2 |
|
231 | 231 | issues_013: |
|
232 |
created_on: <%= 5.days.ago.to_ |
|
|
232 | created_on: <%= 5.days.ago.to_s(:db) %> | |
|
233 | 233 | project_id: 3 |
|
234 |
updated_on: <%= 2.days.ago.to_ |
|
|
234 | updated_on: <%= 2.days.ago.to_s(:db) %> | |
|
235 | 235 | priority_id: 4 |
|
236 | 236 | subject: Subproject issue two |
|
237 | 237 | id: 13 |
@@ -247,9 +247,9 issues_013: | |||
|
247 | 247 | rgt: 2 |
|
248 | 248 | issues_014: |
|
249 | 249 | id: 14 |
|
250 |
created_on: <%= 15.days.ago.to_ |
|
|
250 | created_on: <%= 15.days.ago.to_s(:db) %> | |
|
251 | 251 | project_id: 3 |
|
252 |
updated_on: <%= 15.days.ago.to_ |
|
|
252 | updated_on: <%= 15.days.ago.to_s(:db) %> | |
|
253 | 253 | priority_id: 5 |
|
254 | 254 | subject: Private issue on public project |
|
255 | 255 | fixed_version_id: |
@@ -425,6 +425,37 class UserTest < ActiveSupport::TestCase | |||
|
425 | 425 | end |
|
426 | 426 | end |
|
427 | 427 | |
|
428 | def test_today_should_return_the_day_according_to_user_time_zone | |
|
429 | preference = User.find(1).pref | |
|
430 | date = Date.new(2012, 05, 15) | |
|
431 | time = Time.gm(2012, 05, 15, 23, 30).utc # 2012-05-15 23:30 UTC | |
|
432 | Date.stubs(:today).returns(date) | |
|
433 | Time.stubs(:now).returns(time) | |
|
434 | ||
|
435 | preference.update_attribute :time_zone, 'Baku' # UTC+4 | |
|
436 | assert_equal '2012-05-16', User.find(1).today.to_s | |
|
437 | ||
|
438 | preference.update_attribute :time_zone, 'La Paz' # UTC-4 | |
|
439 | assert_equal '2012-05-15', User.find(1).today.to_s | |
|
440 | ||
|
441 | preference.update_attribute :time_zone, '' | |
|
442 | assert_equal '2012-05-15', User.find(1).today.to_s | |
|
443 | end | |
|
444 | ||
|
445 | def test_time_to_date_should_return_the_date_according_to_user_time_zone | |
|
446 | preference = User.find(1).pref | |
|
447 | time = Time.gm(2012, 05, 15, 23, 30).utc # 2012-05-15 23:30 UTC | |
|
448 | ||
|
449 | preference.update_attribute :time_zone, 'Baku' # UTC+4 | |
|
450 | assert_equal '2012-05-16', User.find(1).time_to_date(time).to_s | |
|
451 | ||
|
452 | preference.update_attribute :time_zone, 'La Paz' # UTC-4 | |
|
453 | assert_equal '2012-05-15', User.find(1).time_to_date(time).to_s | |
|
454 | ||
|
455 | preference.update_attribute :time_zone, '' | |
|
456 | assert_equal '2012-05-15', User.find(1).time_to_date(time).to_s | |
|
457 | end | |
|
458 | ||
|
428 | 459 | def test_fields_for_order_statement_should_return_fields_according_user_format_setting |
|
429 | 460 | with_settings :user_format => 'lastname_coma_firstname' do |
|
430 | 461 | assert_equal ['users.lastname', 'users.firstname', 'users.id'], User.fields_for_order_statement |
General Comments 0
You need to be logged in to leave comments.
Login now