I have some doubts about the leap years, how can I be sure that by using a formula like this
add.years= function(x,y){
if(!isTRUE(all.equal(y,round(y))))
A year is a leap year if:
That is why 2000 was a leap year (although it's divisible by 100, it's also divisible by 400).
But generally, if you have a library that can take of date/time calculations then use it. It's very complicated to do these calculations and easy to do wrong, especially with ancient dates (calendar reforms) and timezones involved.