Pad time with zeros when saving temperature too
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
ScrollView
|
||||
} from 'react-native'
|
||||
import DateTimePicker from 'react-native-modal-datetime-picker-nevo'
|
||||
import padWithZeros from '../../helpers/pad-time-with-zeros'
|
||||
|
||||
import { getPreviousTemperature, saveSymptom } from '../../../db'
|
||||
import styles from '../../../styles'
|
||||
@@ -126,7 +127,7 @@ export default class Temp extends Component {
|
||||
isVisible={this.state.isTimePickerVisible}
|
||||
onConfirm={jsDate => {
|
||||
this.setState({
|
||||
time: `${jsDate.getHours()}:${jsDate.getMinutes()}`,
|
||||
time: padWithZeros(jsDate),
|
||||
isTimePickerVisible: false
|
||||
})
|
||||
}}
|
||||
@@ -201,6 +202,7 @@ class TempInput extends Component {
|
||||
}
|
||||
|
||||
function isInvalidTime(timeString) {
|
||||
console.log(timeString)
|
||||
try {
|
||||
LocalTime.parse(timeString)
|
||||
} catch (err) {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
export default function (jsDate) {
|
||||
const vals = [jsDate.getHours(), jsDate.getMinutes()]
|
||||
return vals.map(val => {
|
||||
if (parseInt(val) < 10) {
|
||||
val = `0${val}`
|
||||
}
|
||||
return val
|
||||
}).join(':')
|
||||
}
|
||||
@@ -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(':')
|
||||
}
|
||||
Reference in New Issue
Block a user