Created
March 16, 2020 08:24
-
-
Save oscarcs/ab910e91572dba95b2e7f2774c1654ea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
timeChanged: function() { | |
this.timeHours = this.claim.Time.split(':')[0]; | |
this.timeMinutes = this.claim.Time.split(':')[1].split(' ')[0]; | |
this.timeOfDay = this.claim.Time.split(' ')[1]; | |
console.log(this.timeHours, this.timeMinutes, this.timeOfDay); | |
}, | |
timeEdited: function() { | |
let hours = parseInt(this.timeHours); | |
if (isNaN(hours) || hours > 12 || hours <= 0) { | |
if (hours > 12 && hours < 24) { | |
hours = hours - 12; | |
this.timeOfDay = 'PM'; | |
} | |
else { | |
hours = '01'; | |
} | |
} | |
let minutes = parseInt(this.timeMinutes); | |
if (isNaN(this.timeMinutes) || minutes > 59 || minutes < 0) { | |
minutes = '00'; | |
} | |
hours.toString().padStart(2, '0'); | |
minutes.toString().padStart(2, '0'); | |
this.claim.Time = hours + ':' + minutes + ' ' + this.timeOfDay; | |
this.propertyEdited('Time'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment