title: python epoch to hour with rounding
body: <p>I am first taking an epoch timestamp and converting it to a UTC dt using:</p>
  
  <pre><code>d = datetime.utcfromtimestamp(input_epoch)
  </code></pre>
  
  <p>Using the following SO post: <a href="https://stackoverflow.com/questions/8343385/how-can-i-get-hours-from-a-python-datetime">How can I get hours from a Python datetime?</a>, i am then grabbing the hour:</p>
  
  <pre><code>h = d.hour + d.minute / 60. + d.second / 3600
  </code></pre>
  
  <p>But this maps an epoch that translates to whatever-10:59:59AM to 10AM. I want a function that will map a given epoch to the closest hour using rounding, e.g., hour:00:00-> hour:00:30:00 -> hour, hour:30:01-> hour:59:59 -> hour+1. </p>
  
  <p>My current best idea is to do:</p>
  
  <pre><code>d = datetime.utcfromtimestamp(input_epoch+3600/2)
  </code></pre>
  
  <p>But I am not convinced this is correct. Is there another builtin library function that will do this more rigorously?</p>