summaryrefslogtreecommitdiffstats
path: root/app/models/time_entry.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-04-26 11:59:51 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-04-26 11:59:51 +0000
commita6311a960370af3606ac3a18ce1d45facf318e22 (patch)
tree7fdcff39f4b0a0ffc81d05ccbadc9f82f2a412c4 /app/models/time_entry.rb
parent1d570a40ff1eb51c2a2c7d807c742083c6cfbde6 (diff)
downloadredmine-a6311a960370af3606ac3a18ce1d45facf318e22.tar.gz
redmine-a6311a960370af3606ac3a18ce1d45facf318e22.zip
Estimated time recognizes improved time formats (#1092).
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1361 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/time_entry.rb')
-rw-r--r--app/models/time_entry.rb14
1 files changed, 1 insertions, 13 deletions
diff --git a/app/models/time_entry.rb b/app/models/time_entry.rb
index 0dce253c7..ddaff2b60 100644
--- a/app/models/time_entry.rb
+++ b/app/models/time_entry.rb
@@ -40,19 +40,7 @@ class TimeEntry < ActiveRecord::Base
end
def hours=(h)
- s = h.dup
- if s.is_a?(String)
- s.strip!
- unless s =~ %r{^[\d\.,]+$}
- # 2:30 => 2.5
- s.gsub!(%r{^(\d+):(\d+)$}) { $1.to_i + $2.to_i / 60.0 }
- # 2h30, 2h, 30m
- s.gsub!(%r{^((\d+)\s*(h|hours?))?\s*((\d+)\s*(m|min)?)?$}) { |m| ($1 || $4) ? ($2.to_i + $5.to_i / 60.0) : m[0] }
- end
- # 2,5 => 2.5
- s.gsub!(',', '.')
- end
- write_attribute :hours, s
+ write_attribute :hours, (h.is_a?(String) ? h.to_hours : h)
end
# tyear, tmonth, tweek assigned where setting spent_on attributes