From 984099f083b4266769843ec31864a2947fdc0825 Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Tue, 10 May 2011 12:27:28 +0200 Subject: [PATCH] fall back to monday if first day of week is not set --- lib/report/operator.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/report/operator.rb b/lib/report/operator.rb index f3c832f644..0d21f4a136 100644 --- a/lib/report/operator.rb +++ b/lib/report/operator.rb @@ -36,8 +36,14 @@ 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 + (Integer(I18n.t(:general_first_day_of_week)) % 7) - 1).days + offset ||= 0 + first_day = begin + Integer I18n.t(:general_first_day_of_week) + rescue ArgumentError + 1 # assume mondays + end + + from = Time.now.utc.at_beginning_of_week + (first_day % 7) - 1).days from -= offset.days '<>d'.to_operator.modify query, field, from, from + 7.days end