From: Jean-Philippe Lang Date: Sun, 23 Mar 2008 16:16:55 +0000 (+0000) Subject: Fixed: 'This week' condition in filter consider monday as the first day of the week... X-Git-Tag: 0.7.0-RC1~15 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=051875429eee26c964208c683ad1f131f6a8c054;p=redmine.git 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 --- 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 "!~"