]> source.dussan.org Git - redmine.git/commitdiff
Fixed: Pre-filled time tracking date ignores timezone (#4160).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 6 Nov 2009 19:41:03 +0000 (19:41 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 6 Nov 2009 19:41:03 +0000 (19:41 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3012 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/timelog_controller.rb
app/models/user.rb

index 103168ea8d571065fd2c449e38bd7027c72e8663..4355141c7b89c5efac25a93413b16c3abb71cf2e 100644 (file)
@@ -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 })
index 6922cb51a2356d42d5d9378bd4d5dac1705a4655..3e852aca3c3ea00f32f6fa67b84a2e61cbda0cee 100644 (file)
@@ -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