Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
19 lines (14 sloc) 565 Bytes
---
layout: post
title: How many days in a month
date: 2010-01-31 23:37:42
updated: 2010-09-23 21:58:30
---
<div class="narrow-col">
<p>The following returns the amount of days in a given year and month, including leap years.</p>
{% highlight ruby %}
(Date.new(year, 12, 31) << (12-month)).day
{% endhighlight %}
<p>The beauty of Ruby.</p>
<p>Credits to <span class="vcard"><span class="fn">Tim Morgan</span></span> for his <a href="https://web.archive.org/web/20090303110452/http://snippets.dzone.com/posts/show/4397">snippet</a>.</p>
</div>