Skip to content

Commit

Permalink
Merge pull request #89 from Veejer/master
Browse files Browse the repository at this point in the history
#85 fix.
  • Loading branch information
daringer committed Sep 18, 2022
2 parents 8cc1e60 + 7dc1d76 commit 74baad7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/config-ref.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ Apart from that `modify` is very powerful, see [advanced cell formatting](https:
* `hours_passed`
* `hours_mins_passed`
* `number`
* `duration`
* `duration_h`

Feel free to contribute, just share your best `modify` line to allow others to use them, too.

Expand Down
19 changes: 18 additions & 1 deletion flex-table-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,24 @@ class CellFormatters {
const minr = Math.floor(minutes);
return (!isNaN(hours) && !isNaN(minr)) ? hours + " hours " + minr + " minutes" : null;
}

duration(data) {
let h = (data > 3600) ? Math.floor(data / 3600).toString() + ':' : '';
let m = (data > 60) ? Math.floor((data % 3600) / 60).toString().padStart(2, 0) + ':' : '';
let s = (data > 0) ? Math.floor((data % 3600) % 60).toString() : '';
if (m) s = s.padStart(2, 0);
return h + m + s;
}
duration_h(data) {
let d = (data > 86400) ? Math.floor(data / 86400).toString() + 'd ' : '';
let h = (data > 3600) ? Math.floor((data % 86400) / 3600) : ''
h = (d) ? h.toString().padStart(2,0) + ':' : ((h) ? h.toString() + ':' : '');

let m = (data > 60) ? Math.floor((data % 3600) / 60).toString().padStart(2, 0) + ':' : '';
let s = (data > 0) ? Math.floor((data % 3600) % 60).toString() : '';
if (m) s = s.padStart(2, 0);
return d + h + m + s;
}


}

Expand Down

0 comments on commit 74baad7

Please sign in to comment.