mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-21 09:40:13 +01:00
Don't round in ttc.min_sec method
This fixes a bug where it would round 1.8 days up to 2 days, and still display the extra hours in addition.
This commit is contained in:
parent
03282638af
commit
c4433a5ea9
2 changed files with 9 additions and 1 deletions
|
|
@ -23,7 +23,7 @@ module Stats
|
||||||
def min_sec
|
def min_sec
|
||||||
min_sec = arbitrary_day + min_in_seconds # convert to a datetime
|
min_sec = arbitrary_day + min_in_seconds # convert to a datetime
|
||||||
@min_sec = min_sec.strftime("%H:%M:%S")
|
@min_sec = min_sec.strftime("%H:%M:%S")
|
||||||
@min_sec = min.round.to_s + " days " + @min_sec if min >= 1
|
@min_sec = min.floor.to_s + " days " + @min_sec if min >= 1
|
||||||
@min_sec
|
@min_sec
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -81,5 +81,13 @@ class TimeToCompleteTest < Test::Unit::TestCase
|
||||||
assert_equal 1.8, ttc.max
|
assert_equal 1.8, ttc.max
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_min_sec_with_almost_two_days
|
||||||
|
start_time = Time.utc(2012, 12, 30, 8, 0, 0)
|
||||||
|
task = FakeTask.new(start_time, now)
|
||||||
|
stats = Stats::TimeToComplete.new([task])
|
||||||
|
assert_equal 2.8, stats.min
|
||||||
|
assert_equal '2 days 19:04:05', stats.min_sec
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue