title: Round a POSIX date (POSIXct) with base R functionality
body: <p>I'm currently playing around a lot with dates and times for a package I'm building.</p>
  
  <p>Stumbling across this <a href="https://stackoverflow.com/questions/8333838/how-do-you-generate-a-sequence-of-the-last-day-of-the-month-over-two-years-in-r">post</a> reminded me again that it's generally not a bad idea to check out if something can be done with basic R features before turning to contrib packages. </p>
  
  <p>Thus, is it possible to round a date of class <code>POSIXct</code> with base R functionality?</p>
  
  <p>I checked</p>
  
  <pre><code>methods(round)
  </code></pre>
  
  <p>which "only" gave me </p>
  
  <pre><code>[1] round.Date      round.timeDate*
  
     Non-visible functions are asterisked
  </code></pre>
  
  <p>This is what I'd like to do (Pseudo Code)</p>
  
  <pre><code>x &lt;- as.POSIXct(Sys.time())
  [1] "2012-07-04 10:33:55 CEST"
  
  round(x, atom="minute")
  [1] "2012-07-04 10:34:00 CEST"
  
  round(x, atom="hour")
  [1] "2012-07-04 11:00:00 CEST"
  
  round(x, atom="day")
  [1] "2012-07-04 CEST"
  </code></pre>
  
  <p>I know this can be done with <a href="http://cran.r-project.org/web/packages/timeDate/index.html" rel="noreferrer">timeDate</a>, <a href="http://cran.r-project.org/web/packages/lubridate/index.html" rel="noreferrer">lubridate</a> etc., but I'd like to keep package dependencies down. So before going ahead and checking out the source code of the respective packages, I thought I'd ask if someone has already done something like this.</p>