Merge pull request #12 from commonCereal/more-than-hour-durations

Update Duration Accumulation to support displaying durations longer than 24 hours
Closes #11
This commit is contained in:
Ell 2022-11-23 18:07:22 +01:00 committed by GitHub
commit e7815334b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 803 additions and 336 deletions

1115
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -204,6 +204,12 @@ function formatTimestamp(timestamp: number, settings: SimpleTimeTrackerSettings)
function formatDuration(totalTime: number): string { function formatDuration(totalTime: number): string {
let duration = moment.duration(totalTime); let duration = moment.duration(totalTime);
let ret = ""; 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) if (duration.hours() > 0)
ret += duration.hours() + "h "; ret += duration.hours() + "h ";
if (duration.minutes() > 0) if (duration.minutes() > 0)

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,11 @@
# 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}
]}
```