Updated formatting of duration to allow for more than 1 24 hour day durations.

This commit is contained in:
Kyle Ferguson 2022-11-23 09:53:04 -07:00
parent 402b97c799
commit 85ee96f5dd
2 changed files with 18 additions and 0 deletions

View file

@ -204,6 +204,12 @@ function formatTimestamp(timestamp: number, settings: SimpleTimeTrackerSettings)
function formatDuration(totalTime: number): string {
let duration = moment.duration(totalTime);
let ret = "";
if (duration.years() > 0)
ret += duration.years() + "y ";
if (duration.months() > 0)
ret += duration.months() + "m ";
if (duration.days() > 0)
ret += duration.days() + "d ";
if (duration.hours() > 0)
ret += duration.hours() + "h ";
if (duration.minutes() > 0)

View file

@ -0,0 +1,12 @@
# Notes
More notes for my cool project! This note shows that we can correctly display accumulated time that lasts longer than a 24 hour day!
```simple-time-tracker
{"entries":[
{"name":"test","startTime":1596265200,"endTime":1627887600,"subEntries":null},
{"name":"test","startTime":1627801200,"endTime":1633158000,"subEntries":null},
{"name":"test","startTime":1659337200,"endTime":1659423600,"subEntries":null},
{"name":"test","startTime":1664627410,"endTime":1664631605,"subEntries":null}
]}
```