You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When calling .add on a moment object, the object is mutated in a way which is hard to debug. For example:
const{ expect }=require('chai');constmoment=require('moment');constdate1=moment(newDate('2018-03-04'));expect(date1.format('YYYY-MM-DD')).to.equal('2018-03-04');// succeedsconstdate2=date1.add(3,'days');// this *mutates* date1 so that date1 is now 2018-03-07 (!)expect(date2.format('YYYY-MM-DD')).to.equal('2018-03-07');// succeedsexpect(date1.format('YYYY-MM-DD')).to.equal('2018-03-04');// FAIL: date1 has been mutated
Environment:
Node.JS v8.9.1 on Ubuntu 17.10 (this really doesn't matter)
We're aware of this. Personally, I don't love the mutability, but we haven't released 3.0 (it's been a few years - see more info here).
One of the moment contributors just released Luxon which has an immutable API. If you (or any folks reading) want to help us release an immutable version of Moment, let us know.
Description of the Issue and Steps to Reproduce:
When calling
.add
on amoment
object, the object is mutated in a way which is hard to debug. For example:Environment:
Node.JS v8.9.1 on Ubuntu 17.10 (this really doesn't matter)
Output of the following:
Ensure your issue is isolated to moment. Issues involving third party tools will be closed unless submitted by the tool's author/maintainer.
The text was updated successfully, but these errors were encountered: