title: How to account for leap years?
body: <p>I have some doubts about the leap years, how can I be sure that by using a formula like this</p>
  
  <pre><code>add.years= function(x,y){    
  if(!isTRUE(all.equal(y,round(y)))) stop("Argument \"y\" must be an integer.\n")
  x &lt;- as.POSIXlt(x)
  x$year &lt;- x$year+y
  as.Date(x)
  }
  </code></pre>
  
  <p>it will take into account leap years, when adding for example 100 years to my observation dataset? How can I control this?</p>
  
  <p>I have a time series dataset with 50 years of observations:</p>
  
  <pre><code>   date    obs
  1995-01-01 1.0
  1995-01-02 2.0
  1995-01-03 2.5
  ...
  2045-12-30 0.2
  2045-12-31 0.1
  </code></pre>
  
  <p>dataset+100 years</p>
  
  <pre><code>   date    obs
  2095-01-01 1.0
  2095-01-02 2.0
  2095-01-03 2.5
  ...
  2145-12-30 0.2
  2145-12-31 0.1
  </code></pre>
  
  <p>After a basic check, I've noticed that the number of rows is the same for both original and 100 years after dataset. I am not sure if what was before the 29th Februray in a leap year will be now the obs value for the 1st of March in a non-leap year, etc. </p>
  
  <p>I can check leap years using from the <strong>chron library</strong> the function <strong>leap.year</strong>, however I would like to know if there is a simpler way to do this, to be sure that rows with pass days of 29th february that do not exist 100 years after will be deleted, and new days of 29th February are added with NA values.</p>