Pad time with zeros when saving temperature too
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
|||||||
ScrollView
|
ScrollView
|
||||||
} from 'react-native'
|
} from 'react-native'
|
||||||
import DateTimePicker from 'react-native-modal-datetime-picker-nevo'
|
import DateTimePicker from 'react-native-modal-datetime-picker-nevo'
|
||||||
|
import padWithZeros from '../../helpers/pad-time-with-zeros'
|
||||||
|
|
||||||
import { getPreviousTemperature, saveSymptom } from '../../../db'
|
import { getPreviousTemperature, saveSymptom } from '../../../db'
|
||||||
import styles from '../../../styles'
|
import styles from '../../../styles'
|
||||||
@@ -126,7 +127,7 @@ export default class Temp extends Component {
|
|||||||
isVisible={this.state.isTimePickerVisible}
|
isVisible={this.state.isTimePickerVisible}
|
||||||
onConfirm={jsDate => {
|
onConfirm={jsDate => {
|
||||||
this.setState({
|
this.setState({
|
||||||
time: `${jsDate.getHours()}:${jsDate.getMinutes()}`,
|
time: padWithZeros(jsDate),
|
||||||
isTimePickerVisible: false
|
isTimePickerVisible: false
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
@@ -201,6 +202,7 @@ class TempInput extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isInvalidTime(timeString) {
|
function isInvalidTime(timeString) {
|
||||||
|
console.log(timeString)
|
||||||
try {
|
try {
|
||||||
LocalTime.parse(timeString)
|
LocalTime.parse(timeString)
|
||||||
} catch (err) {
|
} 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'
|
} from '../../local-storage'
|
||||||
import styles from '../../styles/index'
|
import styles from '../../styles/index'
|
||||||
import { settings as labels } from '../labels'
|
import { settings as labels } from '../labels'
|
||||||
|
import padWithZeros from '../helpers/pad-time-with-zeros'
|
||||||
|
|
||||||
export default class TempReminderPicker extends Component {
|
export default class TempReminderPicker extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@@ -50,7 +51,7 @@ export default class TempReminderPicker extends Component {
|
|||||||
mode="time"
|
mode="time"
|
||||||
isVisible={this.state.isTimePickerVisible}
|
isVisible={this.state.isTimePickerVisible}
|
||||||
onConfirm={jsDate => {
|
onConfirm={jsDate => {
|
||||||
const time = padWithZeros(`${jsDate.getHours()}:${jsDate.getMinutes()}`)
|
const time = padWithZeros(jsDate)
|
||||||
this.setState({
|
this.setState({
|
||||||
time,
|
time,
|
||||||
isTimePickerVisible: false,
|
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