Fixed duration formatter to properly count lengths longer than 24 hours (#612)
* Fixed durationfield formatter to properly count lengths longer than 24 hours. * formatted DurationField.js with npm prettier
This commit is contained in:
@@ -11,10 +11,13 @@ const DurationField = ({ record = {}, source }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const format = (d) => {
|
const format = (d) => {
|
||||||
const date = new Date(null)
|
const hours = Math.floor(d / 3600)
|
||||||
date.setSeconds(d)
|
const minutes = Math.floor(d / 60) % 60
|
||||||
const fmt = date.toISOString().substr(11, 8)
|
const seconds = d % 60
|
||||||
return fmt.replace(/^00:/, '')
|
return [hours, minutes, seconds]
|
||||||
|
.map((v) => (v < 10 ? '0' + v : v))
|
||||||
|
.filter((v, i) => v !== '00' || i > 0)
|
||||||
|
.join(':')
|
||||||
}
|
}
|
||||||
|
|
||||||
DurationField.propTypes = {
|
DurationField.propTypes = {
|
||||||
|
|||||||
Reference in New Issue
Block a user