title: How to define custom time interval in d3.js
body: <p>I'm trying to code an interval round function using the <a href="https://github.com/mbostock/d3/wiki/Time-Intervals"><code>d3.js</code> time intervals API</a>.</p>
  
  <p>The thing I want to do is fairly simple: <em>write a function that rounds a time to the nearest 6 hours and returns it as a <code>Date</code> object</em>.</p>
  
  <p>For example:</p>
  
  <ul>
  <li>At 10:30, <code>d3.hour.my6HourRound(new Date)</code> should return 12:00 today</li>
  <li>At 12:30, <code>d3.hour.my6HourRound(new Date)</code> should return 12:00 today</li>
  <li>At 23:50, <code>d3.hour.my6HourRound(new Date)</code> should return 00:00 tomorrow</li>
  </ul>
  
  <p>It must not be so difficult, but <code>d3.js</code> api lacks of usage demos in API.</p>