Project

General

Profile

Actions

Defect #40914

open

Rounding error in my/page -> timelog

Added by Boris Brodski 5 days ago. Updated about 6 hours ago.

Status:
Confirmed
Priority:
Normal
Assignee:
-
Category:
Time tracking
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Affected version:

Description

On the page my/page, if the timelog is displayed, the total is shown at the top of the table. The summing is not correctly implemented, leading to rounding errors.

Reproduction and Example:

  1. Add time entries for one day, one issue:
    - 0:10
    - 0:40
    - 0:10
  2. Navigate to my/page
  3. Add the 'timelog' widget if it is not already present.
  4. The time entries should be shown. The total displayed is 1:01.

Implementation and Easy Fix:

Current implementation (app/views/my/blocks/_timelog.html.erb:45):

html_hours(format_hours(entries_by_day[day].sum(&:hours)))

Summing hours introduces rounding errors. To fix this, convert to minutes first:

html_hours(format_hours(entries_by_day[day].map{|t| (t.hours * 60).to_i}.sum / 60))

Files


Related issues

Related to Redmine - Defect #36897: Wrong formatting of date in Time EntriesConfirmed

Actions
Actions

Also available in: Atom PDF