Skip to content

Commit

Permalink
Merge pull request #38 from abublihi/momentWorkaround
Browse files Browse the repository at this point in the history
Workaround: sometimes moment wont set the date, by @ronrother
  • Loading branch information
xsoh authored May 30, 2018
2 parents 3e33f26 + eb7ab75 commit 00f2917
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions moment-hijri.js
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,10 @@
lastDay = Math.min(h.hd, hMoment.iDaysInMonth(input, h.hm))
g = toGregorian(input, h.hm, lastDay)
setDate(this, g.gy, g.gm, g.gd)
//Workaround: sometimes moment wont set the date correctly if current day is the last in the month
if (this.month() !== g.gm || this.date() !== g.gd || this.year() !== g.gy) {
setDate(this, g.gy, g.gm, g.gd)
}
moment.updateOffset(this)
return this
} else {
Expand Down Expand Up @@ -673,6 +677,10 @@
}
g = toGregorian(this.iYear(), input, lastDay)
setDate(this, g.gy, g.gm, g.gd)
//Workaround: sometimes moment wont set the date correctly if current day is the last in the month
if (this.month() !== g.gm || this.date() !== g.gd || this.year() !== g.gy) {
setDate(this, g.gy, g.gm, g.gd)
}
moment.updateOffset(this)
return this
} else {
Expand All @@ -686,6 +694,10 @@
h = toHijri(this.year(), this.month(), this.date())
g = toGregorian(h.hy, h.hm, input)
setDate(this, g.gy, g.gm, g.gd)
//Workaround: sometimes moment wont set the date correctly if current day is the last in the month
if (this.month() !== g.gm || this.date() !== g.gd || this.year() !== g.gy) {
setDate(this, g.gy, g.gm, g.gd)
}
moment.updateOffset(this)
return this
} else {
Expand Down

0 comments on commit 00f2917

Please sign in to comment.