From 34f6a60229c71874bfa85323c4f998f5381436ca Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Tue, 10 May 2011 12:05:47 +0200 Subject: [PATCH 1/3] use UTC week --- lib/report/operator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/report/operator.rb b/lib/report/operator.rb index 320b1be46f..42f175fa65 100644 --- a/lib/report/operator.rb +++ b/lib/report/operator.rb @@ -37,7 +37,7 @@ class Report::Operator new "w", :arity => 0, :label => :label_this_week do def modify(query, field, offset = nil) offset ||= 0 - from = Time.now.at_beginning_of_week - ((I18n.t(:general_first_day_of_week).to_i % 7) + 1).days + from = Time.now.utc.at_beginning_of_week - ((I18n.t(:general_first_day_of_week).to_i % 7) + 1).days from -= offset.days '<>d'.to_operator.modify query, field, from, from + 7.days end From caf476b00351df23441ab0dc4a1d9832cc2bf9f3 Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Tue, 10 May 2011 12:13:50 +0200 Subject: [PATCH 2/3] fix week start offset --- lib/report/operator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/report/operator.rb b/lib/report/operator.rb index 42f175fa65..2785d7ad1a 100644 --- a/lib/report/operator.rb +++ b/lib/report/operator.rb @@ -37,7 +37,7 @@ class Report::Operator new "w", :arity => 0, :label => :label_this_week do def modify(query, field, offset = nil) offset ||= 0 - from = Time.now.utc.at_beginning_of_week - ((I18n.t(:general_first_day_of_week).to_i % 7) + 1).days + from = Time.now.utc.at_beginning_of_week + ((I18n.t(:general_first_day_of_week).to_i % 7) - 1).days from -= offset.days '<>d'.to_operator.modify query, field, from, from + 7.days end From 6aceb24c6969f7c38660436104a159b4868adaf9 Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Tue, 10 May 2011 12:17:04 +0200 Subject: [PATCH 3/3] fail loud and clear if general_first_day_of_week is missing --- lib/report/operator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/report/operator.rb b/lib/report/operator.rb index 2785d7ad1a..f3c832f644 100644 --- a/lib/report/operator.rb +++ b/lib/report/operator.rb @@ -37,7 +37,7 @@ class Report::Operator new "w", :arity => 0, :label => :label_this_week do def modify(query, field, offset = nil) offset ||= 0 - from = Time.now.utc.at_beginning_of_week + ((I18n.t(:general_first_day_of_week).to_i % 7) - 1).days + from = Time.now.utc.at_beginning_of_week + (Integer(I18n.t(:general_first_day_of_week)) % 7) - 1).days from -= offset.days '<>d'.to_operator.modify query, field, from, from + 7.days end