Pad time with zeros when saving temperature too

This commit is contained in:
Julia Friesel
2018-11-02 16:05:59 +01:00
parent 472edacb92
commit 4aecf69779
3 changed files with 15 additions and 12 deletions
+2 -11
View File
@@ -12,6 +12,7 @@ import {
} from '../../local-storage'
import styles from '../../styles/index'
import { settings as labels } from '../labels'
import padWithZeros from '../helpers/pad-time-with-zeros'
export default class TempReminderPicker extends Component {
constructor(props) {
@@ -50,7 +51,7 @@ export default class TempReminderPicker extends Component {
mode="time"
isVisible={this.state.isTimePickerVisible}
onConfirm={jsDate => {
const time = padWithZeros(`${jsDate.getHours()}:${jsDate.getMinutes()}`)
const time = padWithZeros(jsDate)
this.setState({
time,
isTimePickerVisible: false,
@@ -71,13 +72,3 @@ export default class TempReminderPicker extends Component {
)
}
}
function padWithZeros(time) {
const vals = time.split(':')
return vals.map(val => {
if (parseInt(val) < 10) {
val = `0${val}`
}
return val
}).join(':')
}