From: Jean-Philippe Lang Date: Fri, 6 Nov 2009 19:41:03 +0000 (+0000) Subject: Fixed: Pre-filled time tracking date ignores timezone (#4160). X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=6245f49934d2f2444d4313a800c14e17931f8c0b;p=redminele%2Fredmine.git Fixed: Pre-filled time tracking date ignores timezone (#4160). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3012 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/controllers/timelog_controller.rb b/app/controllers/timelog_controller.rb index 103168ea..4355141c 100644 --- a/app/controllers/timelog_controller.rb +++ b/app/controllers/timelog_controller.rb @@ -210,7 +210,7 @@ class TimelogController < ApplicationController def edit render_403 and return if @time_entry && !@time_entry.editable_by?(User.current) - @time_entry ||= TimeEntry.new(:project => @project, :issue => @issue, :user => User.current, :spent_on => Date.today) + @time_entry ||= TimeEntry.new(:project => @project, :issue => @issue, :user => User.current, :spent_on => User.current.today) @time_entry.attributes = params[:time_entry] call_hook(:controller_timelog_edit_before_save, { :params => params, :time_entry => @time_entry }) diff --git a/app/models/user.rb b/app/models/user.rb index 6922cb51..3e852aca 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -224,6 +224,15 @@ class User < Principal name end + # Returns the current day according to user's time zone + def today + if time_zone.nil? + Date.today + else + Time.now.in_time_zone(time_zone).to_date + end + end + def logged? true end