Open GoogleCodeExporter opened 9 years ago
Example of what I need:
start date: 01 Mar 2012
end date: 28 Feb 2013
thanks.
Original comment by jose.ros...@gmail.com
on 27 Feb 2012 at 12:30
I've got the solution:
var start = Date.today();
var end = Date.parse(start, "d-MMM-yyyy");
if (end.toString('d/M') != '29/02') {
end.addDays(-1); //in case that it isn't 29 of Feb, we remove a day
}
end.addYears(1);
console.log(end);
thanks.
Original comment by jose.ros...@gmail.com
on 27 Feb 2012 at 12:54
It's because you're parsing the Start var - it returns the object so the end
var function ends up mutating the original object (which end ends up as a
reference to).
var start = Date.today();
var end = Date.today();
end.addYears(1);
That works as expected, no mutation of the object. Maybe it should clone it...?
Original comment by darkcr...@gmail.com
on 16 Sep 2013 at 4:33
patched it so it clones the object if it's an instance of a date object in my
fork:
https://github.com/abritinthebay/datejs/
Original comment by darkcr...@gmail.com
on 16 Sep 2013 at 4:45
Original issue reported on code.google.com by
jose.ros...@gmail.com
on 27 Feb 2012 at 12:13