From e693c045b80a4d11aa64f648dfed82dcca7651f2 Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Wed, 11 May 2011 16:42:41 +0200 Subject: [PATCH 1/4] simply force UTC TZ rather than converting time --- lib/report/operator.rb | 6 +++--- lib/to_date_patch.rb | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/report/operator.rb b/lib/report/operator.rb index 8365ea029d..a2fc719eb7 100644 --- a/lib/report/operator.rb +++ b/lib/report/operator.rb @@ -43,7 +43,7 @@ class Report::Operator 1 # assume mondays end - from = Time.now.utc.at_beginning_of_week + ((first_day % 7) - 1).days + from = Time.now.force_utc.at_beginning_of_week + ((first_day % 7) - 1).days from -= offset.days '<>d'.to_operator.modify query, field, from, from + 7.days end @@ -277,8 +277,8 @@ class Report::Operator module DateRange def modify(query, field, from, to) - query.where ["#{field} > '%s'", quoted_date((Date.yesterday + from).to_time.utc.end_of_day)] if from - query.where ["#{field} <= '%s'", quoted_date((Date.today + to).to_time.utc.end_of_day)] if to + query.where ["#{field} > '%s'", quoted_date((Date.yesterday + from).to_time.force_utc.end_of_day)] if from + query.where ["#{field} <= '%s'", quoted_date((Date.today + to).to_time.force_utc.end_of_day)] if to query end end diff --git a/lib/to_date_patch.rb b/lib/to_date_patch.rb index 4bac1c94fb..2f9dd1e8cb 100644 --- a/lib/to_date_patch.rb +++ b/lib/to_date_patch.rb @@ -9,6 +9,11 @@ module ToDatePatch return Date.today if blank? Date.parse self end + + def force_utc + return self if utc? + utc - utc_offset + end end module DateAndTime From 88c01dea805b83842ae39d893f77fdd07ded9bde Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Wed, 11 May 2011 16:47:20 +0200 Subject: [PATCH 2/4] fix force_utc --- lib/to_date_patch.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/to_date_patch.rb b/lib/to_date_patch.rb index 2f9dd1e8cb..3af633ee50 100644 --- a/lib/to_date_patch.rb +++ b/lib/to_date_patch.rb @@ -9,11 +9,6 @@ module ToDatePatch return Date.today if blank? Date.parse self end - - def force_utc - return self if utc? - utc - utc_offset - end end module DateAndTime @@ -23,5 +18,11 @@ module ToDatePatch def to_dateish self end + + def force_utc + return to_time.force_utc unless repond_to? :utc_offset + return self if utc? + utc - utc_offset + end end end From e7f2faf1c3f0d27fabdb7bd085741b8aa61bb2b1 Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Wed, 11 May 2011 16:52:13 +0200 Subject: [PATCH 3/4] fix force_utc --- lib/to_date_patch.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/to_date_patch.rb b/lib/to_date_patch.rb index 3af633ee50..cf98973db8 100644 --- a/lib/to_date_patch.rb +++ b/lib/to_date_patch.rb @@ -20,7 +20,7 @@ module ToDatePatch end def force_utc - return to_time.force_utc unless repond_to? :utc_offset + return to_time.force_utc unless respond_to? :utc_offset return self if utc? utc - utc_offset end From 30fc64e4fbb5383905b4ade47e893121d5611cda Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Wed, 11 May 2011 16:59:47 +0200 Subject: [PATCH 4/4] dont use UTC --- lib/report/operator.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/report/operator.rb b/lib/report/operator.rb index a2fc719eb7..c01386d49f 100644 --- a/lib/report/operator.rb +++ b/lib/report/operator.rb @@ -43,7 +43,7 @@ class Report::Operator 1 # assume mondays end - from = Time.now.force_utc.at_beginning_of_week + ((first_day % 7) - 1).days + from = Time.now.at_beginning_of_week + ((first_day % 7) - 1).days from -= offset.days '<>d'.to_operator.modify query, field, from, from + 7.days end @@ -277,8 +277,8 @@ class Report::Operator module DateRange def modify(query, field, from, to) - query.where ["#{field} > '%s'", quoted_date((Date.yesterday + from).to_time.force_utc.end_of_day)] if from - query.where ["#{field} <= '%s'", quoted_date((Date.today + to).to_time.force_utc.end_of_day)] if to + query.where ["#{field} > '%s'", quoted_date((Date.yesterday + from).to_time.end_of_day)] if from + query.where ["#{field} <= '%s'", quoted_date((Date.today + to).to_time.end_of_day)] if to query end end