Merge branch 'master' into stats
This commit is contained in:
commit
0e6b9030f8
@ -417,6 +417,16 @@
|
||||
"node": {
|
||||
"extensions": [".js", ".jsx"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"react": {
|
||||
"createClass": "createReactClass",
|
||||
"pragma": "React",
|
||||
"version": "16.6"
|
||||
},
|
||||
"propWrapperFunctions": [
|
||||
"forbidExtraProps",
|
||||
{"property": "freeze", "object": "Object"},
|
||||
{"property": "myFavoriteWrapper"}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ class Statistics extends React.Component {
|
||||
tickFormatter={value => displayedData === 'distance'
|
||||
? `${value} km`
|
||||
: displayedData === 'duration'
|
||||
? format(formatDuration(value), 'HH:mm')
|
||||
? formatDuration(value)
|
||||
: value
|
||||
}
|
||||
/>
|
||||
|
@ -1,10 +1,9 @@
|
||||
import React from 'react'
|
||||
import { format } from 'date-fns'
|
||||
|
||||
import { formatDuration } from '../../utils'
|
||||
|
||||
const formatValue = (displayedData, value) => displayedData === 'duration'
|
||||
? format(formatDuration(value), 'HH:mm')
|
||||
? formatDuration(value, true)
|
||||
: displayedData === 'distance'
|
||||
? value.toFixed(3)
|
||||
: value
|
||||
|
@ -92,7 +92,7 @@ class Statistics extends React.Component {
|
||||
tickFormatter={value => displayedData === 'distance'
|
||||
? `${value} km`
|
||||
: displayedData === 'duration'
|
||||
? format(formatDuration(value), 'HH:mm')
|
||||
? formatDuration(value)
|
||||
: value
|
||||
}
|
||||
/>
|
||||
|
@ -123,7 +123,7 @@ const user = (state = initial.user, action) => {
|
||||
const statistics = (state = initial.statistics, action) =>
|
||||
handleDataAndError(state, 'statistics', action)
|
||||
|
||||
export default (history) => combineReducers({
|
||||
export default history => combineReducers({
|
||||
activities,
|
||||
calendarActivities,
|
||||
chartData,
|
||||
|
@ -1,6 +1,6 @@
|
||||
import togeojson from '@mapbox/togeojson'
|
||||
import {
|
||||
addDays, addMonths, addYears, format, parse, startOfWeek, subHours
|
||||
addDays, addMonths, addYears, format, parse, startOfWeek
|
||||
} from 'date-fns'
|
||||
import { DateTime } from 'luxon'
|
||||
|
||||
@ -125,10 +125,24 @@ export const formatRecord = (record, tz) => {
|
||||
}
|
||||
}
|
||||
|
||||
export const formatDuration = seconds => {
|
||||
let newDate = new Date(0)
|
||||
newDate = subHours(newDate.setSeconds(seconds), 1)
|
||||
return newDate.getTime()
|
||||
export const formatDuration = (totalSeconds, formatWithDay = false) => {
|
||||
let days = '0'
|
||||
if (formatWithDay) {
|
||||
days = String(Math.floor(totalSeconds / 86400))
|
||||
totalSeconds %= 86400
|
||||
}
|
||||
const hours = String(Math.floor(totalSeconds / 3600)).padStart(2, '0')
|
||||
totalSeconds %= 3600
|
||||
const minutes = String(Math.floor(totalSeconds / 60)).padStart(2, '0')
|
||||
const seconds = String(totalSeconds % 60).padStart(2, '0')
|
||||
if (formatWithDay) {
|
||||
return `${
|
||||
days === '0' ? '' : `${days}d:`
|
||||
}${
|
||||
hours === '00' ? '' : `${hours}h:`
|
||||
}${minutes}m:${seconds}s`
|
||||
}
|
||||
return `${hours === '00' ? '' : `${hours}:`}${minutes}:${seconds}`
|
||||
}
|
||||
|
||||
export const formatChartData = chartData => {
|
||||
|
Loading…
Reference in New Issue
Block a user