OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Prevent rounding of hours for time tracking
Kushal Pandya690e7b7f26b6
diff --git a/frontend/src/app/shared/helpers/chronic_duration.spec.ts b/frontend/src/app/shared/helpers/chronic_duration.spec.tsindex 95fc4fd3de3..f0418c58c3e 100644--- a/frontend/src/app/shared/helpers/chronic_duration.spec.ts+++ b/frontend/src/app/shared/helpers/chronic_duration.spec.ts@@ -382,9 +382,9 @@ describe('outputChronicDuration', () => {).toBe('6 months 1 day 1 hour');});- it('returns hours only if hoursOnly option specified, rounded to nearest hour', () => {+ it('returns hours only if hoursOnly option specified', () => {expect(outputChronicDuration(60 * 60 * 24 * 3 + 60 * 60 * 3, { hoursOnly: true })).toBe('75h');- expect(outputChronicDuration(4 * 3600 + 60 + 1, { hoursOnly: true })).toBe('4h');+ expect(outputChronicDuration(4 * 3600 + 45 * 60, { hoursOnly: true })).toBe('4h 45m');expect(outputChronicDuration(5 * 3600, { hoursOnly: true })).toBe('5h');});diff --git a/frontend/src/app/shared/helpers/chronic_duration.ts b/frontend/src/app/shared/helpers/chronic_duration.tsindex 6aca55e4245..fe400da2a22 100644--- a/frontend/src/app/shared/helpers/chronic_duration.ts+++ b/frontend/src/app/shared/helpers/chronic_duration.ts@@ -284,7 +284,12 @@ export function parseChronicDuration(string:string, opts:ChronicDurationOptions// returns a formatted string representing elapsed timeexport function outputChronicDuration(seconds:number, opts:ChronicDurationOptions = {}):string|null {if (opts.hoursOnly) {- const hours = Math.round(seconds / 3600);+ const decimalHours = seconds / 3600;+ const hours = Math.floor(decimalHours);+ if (decimalHours % 1 !== 0) {+ const minutes = Math.round((decimalHours % 1) * 60);+ return `${hours}h ${minutes}m`;+ }return `${hours}h`;}