title: Cut-/Rounding down a DateTime to a Whole i.e. Hour/Day?
body: <p>Is there any kind of mathematical way to cut DateTime down to a exact Hour, Day or so? Similiar to round of a decimal to int.</p>
  
  <p>Period.Day <br>
  If the original value was <code>2011-01-01 13:00:00</code>, it ends up in <code>2011-01-01 00:00:00</code></p>
  
  <p>if Period.Hour <br>
  If the original value was <code>2011-03-11 13:32:00</code>, it ends up in <code>2011-03-11 13:00:00</code></p>
  
  <p>I think about something like below. This are of course works fine, but the <code>range</code>-array are iterated through anyway, later. Better if I was possible to calculate directly on that iteration, instead of it's own. But someType can't be put into that iteration (it depends on someType).</p>
  
  <pre><code>if (someType == Period.Day)
    range.ForEach(d =&gt; d.time = new DateTime(d.time.Year, d.time.Month, d.time.Day,0,0,0));
  if (someType == Period.Hour)
    range.ForEach(d =&gt; d.time = new DateTime(d.time.Year, d.time.Month, d.time.Day, d.time.Hour, 0, 0));
  </code></pre>