fall back to monday if first day of week is not set

pull/6827/head
Konstantin Haase 14 years ago
parent 6aceb24c69
commit 984099f083
  1. 8
      lib/report/operator.rb

@ -37,7 +37,13 @@ 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
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

Loading…
Cancel
Save