Skip to content

Commit

Permalink
Change the way properties are parsed to number
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszpigula committed Mar 1, 2021
1 parent 2b10d0e commit 5ea6ee2
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/plugin/duration/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,17 @@ class Duration {
if (typeof input === 'string') {
const d = input.match(durationRegex)
if (d) {
this.$d.years = Number(d[2])
this.$d.months = Number(d[3])
this.$d.weeks = Number(d[4])
this.$d.days = Number(d[5])
this.$d.hours = Number(d[6])
this.$d.minutes = Number(d[7])
this.$d.seconds = Number(d[8])

const [,, ...properties] = d
const numberD = properties.map(value => Number(value));
[
this.$d.years,
this.$d.months,
this.$d.weeks,
this.$d.days,
this.$d.hours,
this.$d.minutes,
this.$d.seconds
] = numberD
this.calMilliseconds()
return this
}
Expand Down

0 comments on commit 5ea6ee2

Please sign in to comment.