Skip to content

Commit

Permalink
fix: change use of String.padStart to custom method
Browse files Browse the repository at this point in the history
String.padStart is not supported in all enviroments, so the change
  • Loading branch information
Aterbonus committed May 2, 2018
1 parent 5854c25 commit 05e8cd6
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions src/NixieClock.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,17 @@ export default {
methods: {
step() {
if (this.active) {
let date = new Date()
const date = new Date()
this.hours = date
.getHours()
.toString()
.padStart(2, '0')
this.minutes = date
.getMinutes()
.toString()
.padStart(2, '0')
this.seconds = date
.getSeconds()
.toString()
.padStart(2, '0')
this.hours = this.leftPad(date.getHours())
this.minutes = this.leftPad(date.getMinutes())
this.seconds = this.leftPad(date.getSeconds())
requestAnimationFrame(this.step)
}
},
leftPad(number) {
return String(number >= 10 ? number : '0' + number)
}
},
components: {
Expand Down

0 comments on commit 05e8cd6

Please sign in to comment.