I am using quite complex property bindings to be able to change either day, month or year of a user’s birthdate. Having an attr birthDate of type date on a user and three properties for each piece of the date.
I am using moment.js to simplify date manipulations.
By trying the reduced showcase on jsfiddle you’ll see that if you change year or day, the month is always increased by 1. I can’t say what is happening. Just this: when setting the new date, the value is correct and gets changed later. Is there an issue with ember-data date attributes and some formating?
Again: here’s the jsfiddle – written in CoffeeScript.
Thanks in advance!
I looked at your code and it looked like it should be working fine, the more I stepped through it the more I got annoyed that I couldn’t spot the problem … turns out it’s the .month() method from Moment.js … from the docs:
“Mutates the original moment by changing the month. Accepts numbers from 0 to 11”
Pretty dumb huh? In any case change your setMonth to subtract 1 from the value when you use .month()