Skip to content

Commit

Permalink
fix for #424
Browse files Browse the repository at this point in the history
  • Loading branch information
johnleider committed Apr 24, 2017
1 parent d0e8e1a commit 5a45a33
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/components/pickers/TimePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ export default {

let hour = value.getHours()
const minute = value.getMinutes()
let period = ''

if (!this.is24hr) {
hour = hour > 12 ? hour - 12 : hour
period = this.period
}

return `${hour}:${minute}${!this.is24hr ? this.period : ''}`
return `${hour}:${minute}${period}`
},
set (val) {
return this.$emit('input', val)
Expand All @@ -74,10 +76,10 @@ export default {
if (!this.is24hr) {
val = val > 12 ? val - 12 : val < 1 ? 12 : val
} else {
val = val > 23 ? 0 : val
val = val < 10 ? `0${val}` : val > 23 ? '00' : val
}

this.inputTime = `${val}:${this.minute}${this.period}`
this.inputTime = `${val}:${this.minute}${!this.is24hr ? this.period : ''}`
}
},
minute: {
Expand All @@ -88,8 +90,13 @@ export default {
},
set (val) {
val = val < 10 ? `0${parseInt(val)}` : val > 59 ? '00' : val
let hour = this.hour

this.inputTime = `${this.hour}:${val}${this.period}`
if (this.is24hr && hour < 10) {
hour = `0${hour}`
}

this.inputTime = `${hour}:${val}${!this.is24hr ? this.period : ''}`
}
},
clockHand () {
Expand Down

0 comments on commit 5a45a33

Please sign in to comment.