title: Strange behavior in function parsing a date
body: <p>I have a function that takes in a date and converts it to an offset in a matrix.  There is one row in the matrix per 15 minute time period.  I'm sure you could write this more elegantly or efficiently, but this appears to work, at least most of the time.  My problem is when I pass in an array of 16 or more dates to be converted; the results are way off.  Array of 15 appears fine.  Things I tried to make it work: treat the offset as a double (nope), comment out some of the function lines (sometimes it works, sometimes not), print the value out within the function (nope).  Clearly there is something going on here, but I'm out of things to try.  Is it something to do with lubridate?  I've used it similarly before with no problem.  Code is below, hopefully you can reproduce this; even if not please suggest something!</p>
  
  <pre><code>library(lubridate)
  
  test15 &lt;- structure(c(1407992400, 1407994200, 1407995100, 1407996000, 
  1407996900, 1407998700, 1407999600, 1408001400, 1408002300, 1408004100, 
  1408005000, 1408006800, 1408011300, 1408012200, 1408013100), 
  class = c("POSIXct", "POSIXt"), tzone = "Etc/GMT+5")
  test16 &lt;- structure(c(1407992400, 1407994200, 1407995100, 1407996000, 
  1407996900, 1407998700, 1407999600, 1408001400, 1408002300, 1408004100, 
  1408005000, 1408006800, 1408011300, 1408012200, 1408013100, 1407987000), 
  class = c("POSIXct", "POSIXt"), tzone = "Etc/GMT+5")
  #---------------------------------------------------------------------------
  # function to translate timestamp into time step offset
  #---------------------------------------------------------------------------
  study.start &lt;- as.Date("2014-08-13")
  interval &lt;- 15
  
  getoffset &lt;- function(bin.in)
      { #get offset function
      date.offset &lt;-     as.numeric(difftime(as.Date(as.POSIXlt(bin.in)),study.start))
      hour.offset &lt;- hour(bin.in)*(60/interval)
      min.offset &lt;- minute(bin.in)/interval
      step.offset &lt;- date.offset*24*(60/interval) + hour.offset + min.offset
      return(step.offset)
      } #get offset function
  
  getoffset(test15)
  getoffset(test16)
  </code></pre>