mirror of
https://github.com/Ellpeck/ObsidianSimpleTimeTracker.git
synced 2024-11-16 07:23:12 +01:00
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:
commit
e7815334b2
4 changed files with 803 additions and 336 deletions
1115
package-lock.json
generated
1115
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -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)
|
||||
|
|
File diff suppressed because one or more lines are too long
11
test-vault/duration_accumulation_test.md
Normal file
11
test-vault/duration_accumulation_test.md
Normal 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}
|
||||
]}
|
||||
```
|
Loading…
Reference in a new issue