From 051875429eee26c964208c683ad1f131f6a8c054 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 23 Mar 2008 16:16:55 +0000 Subject: [PATCH] Fixed: 'This week' condition in filter consider monday as the first day of the week even if language sets otherwise (closes #913). git-svn-id: http://redmine.rubyforge.org/svn/trunk@1291 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/query.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/query.rb b/app/models/query.rb index 2b708ddda..99d13aa6a 100644 --- a/app/models/query.rb +++ b/app/models/query.rb @@ -339,7 +339,12 @@ class Query < ActiveRecord::Base when "t" sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date(Date.today.to_time), connection.quoted_date((Date.today+1).to_time)] when "w" - sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date(Time.now.at_beginning_of_week), connection.quoted_date(Time.now.next_week.yesterday)] + from = l(:general_first_day_of_week) == '7' ? + # week starts on sunday + ((Date.today.cwday == 7) ? Time.now.at_beginning_of_day : Time.now.at_beginning_of_week - 1.day) : + # week starts on monday (Rails default) + Time.now.at_beginning_of_week + sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date(from), connection.quoted_date(from + 7.days)] when "~" sql = sql + "#{db_table}.#{db_field} LIKE '%#{connection.quote_string(v.first)}%'" when "!~"