<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Calculate age in Rails with a birthday</title>
	<atom:link href="http://jonathanng.com/ruby-on-rails/calculate-age-in-rails-with-a-birthday/feed/" rel="self" type="application/rss+xml" />
	<link>http://jonathanng.com/ruby-on-rails/calculate-age-in-rails-with-a-birthday/</link>
	<description>code + culture</description>
	<lastBuildDate>Fri, 21 Jan 2011 19:11:10 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: CaDs</title>
		<link>http://jonathanng.com/ruby-on-rails/calculate-age-in-rails-with-a-birthday/comment-page-1/#comment-738</link>
		<dc:creator>CaDs</dc:creator>
		<pubDate>Fri, 12 Jun 2009 06:47:07 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanng.com/2008/01/28/calculate-age-in-rails-with-a-birthday/#comment-738</guid>
		<description>This seems to do the job:&lt;br&gt;&lt;br&gt;((Time.now.to_time - birthday.to_time) / 1.years).to_i</description>
		<content:encoded><![CDATA[<p>This seems to do the job:</p>
<p>((Time.now.to_time &#8211; birthday.to_time) / 1.years).to_i</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: NOV</title>
		<link>http://jonathanng.com/ruby-on-rails/calculate-age-in-rails-with-a-birthday/comment-page-1/#comment-269</link>
		<dc:creator>NOV</dc:creator>
		<pubDate>Sat, 10 May 2008 22:20:57 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanng.com/2008/01/28/calculate-age-in-rails-with-a-birthday/#comment-269</guid>
		<description>today, birthday = [Date.today, self].map do &#124;d&#124; 
  d.strftime(&quot;%Y%m%d&quot;).to_i
end
(today - birthday) / 10000</description>
		<content:encoded><![CDATA[<p>today, birthday = [Date.today, self].map do |d|<br />
  d.strftime(&#8220;%Y%m%d&#8221;).to_i<br />
end<br />
(today &#8211; birthday) / 10000</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: NOV</title>
		<link>http://jonathanng.com/ruby-on-rails/calculate-age-in-rails-with-a-birthday/comment-page-1/#comment-832</link>
		<dc:creator>NOV</dc:creator>
		<pubDate>Sat, 10 May 2008 22:20:00 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanng.com/2008/01/28/calculate-age-in-rails-with-a-birthday/#comment-832</guid>
		<description>today, birthday = [Date.today, self].map do &#124;d&#124; 
  d.strftime(&quot;%Y%m%d&quot;).to_i
end
(today - birthday) / 10000</description>
		<content:encoded><![CDATA[<p>today, birthday = [Date.today, self].map do |d|<br />
  d.strftime(&#8220;%Y%m%d&#8221;).to_i<br />
end<br />
(today &#8211; birthday) / 10000</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: NOV</title>
		<link>http://jonathanng.com/ruby-on-rails/calculate-age-in-rails-with-a-birthday/comment-page-1/#comment-267</link>
		<dc:creator>NOV</dc:creator>
		<pubDate>Sat, 10 May 2008 21:56:58 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanng.com/2008/01/28/calculate-age-in-rails-with-a-birthday/#comment-267</guid>
		<description>&lt;pre&gt;
class Date
  def to_age
    integer_style = &quot;%Y%m%d&quot;
    today = Date.today.strftime(integer_style).to_i
    birthday = Date.today.strftime(integer_style).to_i
    (today - birthday) / 10000
  end
end
&lt;/pre&gt;
=&gt; birthday.to_age

If the birthday.class.class_name == Time, you can use below.

http://d.hatena.ne.jp/secondlife/20050922/1127376501</description>
		<content:encoded><![CDATA[<pre>
class Date
  def to_age
    integer_style = "%Y%m%d"
    today = Date.today.strftime(integer_style).to_i
    birthday = Date.today.strftime(integer_style).to_i
    (today - birthday) / 10000
  end
end
</pre>
<p>=&gt; birthday.to_age</p>
<p>If the birthday.class.class_name == Time, you can use below.</p>
<p><a href="http://d.hatena.ne.jp/secondlife/20050922/1127376501" rel="nofollow">http://d.hatena.ne.jp/secondlife/20050922/1127376501</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: NOV</title>
		<link>http://jonathanng.com/ruby-on-rails/calculate-age-in-rails-with-a-birthday/comment-page-1/#comment-831</link>
		<dc:creator>NOV</dc:creator>
		<pubDate>Sat, 10 May 2008 21:56:00 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanng.com/2008/01/28/calculate-age-in-rails-with-a-birthday/#comment-831</guid>
		<description>&lt;pre&gt;
class Date
  def to_age
    integer_style = &quot;%Y%m%d&quot;
    today = Date.today.strftime(integer_style).to_i
    birthday = Date.today.strftime(integer_style).to_i
    (today - birthday) / 10000
  end
end
&lt;/pre&gt;
=&gt; birthday.to_age

If the birthday.class.class_name == Time, you can use below.

http://d.hatena.ne.jp/secondlife/20050922/1127376501</description>
		<content:encoded><![CDATA[<pre>
class Date
  def to_age
    integer_style = "%Y%m%d"
    today = Date.today.strftime(integer_style).to_i
    birthday = Date.today.strftime(integer_style).to_i
    (today - birthday) / 10000
  end
end
</pre>
<p>=&gt; birthday.to_age</p>
<p>If the birthday.class.class_name == Time, you can use below.</p>
<p><a href="http://d.hatena.ne.jp/secondlife/20050922/1127376501" rel="nofollow">http://d.hatena.ne.jp/secondlife/20050922/1127376501</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rolf</title>
		<link>http://jonathanng.com/ruby-on-rails/calculate-age-in-rails-with-a-birthday/comment-page-1/#comment-177</link>
		<dc:creator>rolf</dc:creator>
		<pubDate>Tue, 15 Apr 2008 14:03:39 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanng.com/2008/01/28/calculate-age-in-rails-with-a-birthday/#comment-177</guid>
		<description>&lt;pre&gt;
def age(birthday)
    y=(Date.today.year) - (birthday.year)
    m=(Date.today.month)-(birthday.month)
    d=(Date.today.day)-(birthday.day)
        case 
           when (m&lt;0) 
                      age=y-1 
           when (m=0)
                        case
                            when(d0)
                              age=y
                        end
            when (m&gt;0)
              age=y
         end
    age
  end
&lt;/pre&gt;
</description>
		<content:encoded><![CDATA[<pre>
def age(birthday)
    y=(Date.today.year) - (birthday.year)
    m=(Date.today.month)-(birthday.month)
    d=(Date.today.day)-(birthday.day)
        case
           when (m&lt;0)
                      age=y-1
           when (m=0)
                        case
                            when(d0)
                              age=y
                        end
            when (m&gt;0)
              age=y
         end
    age
  end
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: rolf</title>
		<link>http://jonathanng.com/ruby-on-rails/calculate-age-in-rails-with-a-birthday/comment-page-1/#comment-830</link>
		<dc:creator>rolf</dc:creator>
		<pubDate>Tue, 15 Apr 2008 14:03:00 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanng.com/2008/01/28/calculate-age-in-rails-with-a-birthday/#comment-830</guid>
		<description>&lt;pre&gt;
def age(birthday)
    y=(Date.today.year) - (birthday.year)
    m=(Date.today.month)-(birthday.month)
    d=(Date.today.day)-(birthday.day)
        case 
           when (m&lt;0) 
                      age=y-1 
           when (m=0)
                        case
                            when(d0)
                              age=y
                        end
            when (m&gt;0)
              age=y
         end
    age
  end
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<pre>
def age(birthday)
    y=(Date.today.year) - (birthday.year)
    m=(Date.today.month)-(birthday.month)
    d=(Date.today.day)-(birthday.day)
        case
           when (m&lt;0)
                      age=y-1
           when (m=0)
                        case
                            when(d0)
                              age=y
                        end
            when (m&gt;0)
              age=y
         end
    age
  end
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: rolf</title>
		<link>http://jonathanng.com/ruby-on-rails/calculate-age-in-rails-with-a-birthday/comment-page-1/#comment-176</link>
		<dc:creator>rolf</dc:creator>
		<pubDate>Tue, 15 Apr 2008 13:56:49 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanng.com/2008/01/28/calculate-age-in-rails-with-a-birthday/#comment-176</guid>
		<description>I&#039;ve put the next few lines in my application_helper, I&#039;m using it to calculate the age of people today(but this could be any date), just passing @person.birthday to it. gr rolf

&lt;pre&gt;
  def age(birthday)
    y=(Date.today.year) - (birthday.year)
    m=(Date.today.month)-(birthday.month)
    d=(Date.today.day)-(birthday.day)
        case 
           when (m&lt;0) 
                      age=y-1     #april-mei=-1; april-april=0; april-maart=1#15-15=0; 15-16=-1; 15-13=2
           when (m=0)
                        case
                            when(d0)
                              age=y
                        end
            when (m&gt;0)
              age=y
         end
    age
  end
&lt;/pre&gt;
</description>
		<content:encoded><![CDATA[<p>I&#8217;ve put the next few lines in my application_helper, I&#8217;m using it to calculate the age of people today(but this could be any date), just passing @person.birthday to it. gr rolf</p>
<pre>
  def age(birthday)
    y=(Date.today.year) - (birthday.year)
    m=(Date.today.month)-(birthday.month)
    d=(Date.today.day)-(birthday.day)
        case
           when (m&lt;0)
                      age=y-1     #april-mei=-1; april-april=0; april-maart=1#15-15=0; 15-16=-1; 15-13=2
           when (m=0)
                        case
                            when(d0)
                              age=y
                        end
            when (m&gt;0)
              age=y
         end
    age
  end
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: rolf</title>
		<link>http://jonathanng.com/ruby-on-rails/calculate-age-in-rails-with-a-birthday/comment-page-1/#comment-829</link>
		<dc:creator>rolf</dc:creator>
		<pubDate>Tue, 15 Apr 2008 13:56:00 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanng.com/2008/01/28/calculate-age-in-rails-with-a-birthday/#comment-829</guid>
		<description>I&#039;ve put the next few lines in my application_helper, I&#039;m using it to calculate the age of people today(but this could be any date), just passing @person.birthday to it. gr rolf

&lt;pre&gt;
  def age(birthday)
    y=(Date.today.year) - (birthday.year)
    m=(Date.today.month)-(birthday.month)
    d=(Date.today.day)-(birthday.day)
        case 
           when (m&lt;0) 
                      age=y-1     #april-mei=-1; april-april=0; april-maart=1#15-15=0; 15-16=-1; 15-13=2
           when (m=0)
                        case
                            when(d0)
                              age=y
                        end
            when (m&gt;0)
              age=y
         end
    age
  end
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>I&#8217;ve put the next few lines in my application_helper, I&#8217;m using it to calculate the age of people today(but this could be any date), just passing @person.birthday to it. gr rolf</p>
<pre>
  def age(birthday)
    y=(Date.today.year) - (birthday.year)
    m=(Date.today.month)-(birthday.month)
    d=(Date.today.day)-(birthday.day)
        case
           when (m&lt;0)
                      age=y-1     #april-mei=-1; april-april=0; april-maart=1#15-15=0; 15-16=-1; 15-13=2
           when (m=0)
                        case
                            when(d0)
                              age=y
                        end
            when (m&gt;0)
              age=y
         end
    age
  end
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: api</title>
		<link>http://jonathanng.com/ruby-on-rails/calculate-age-in-rails-with-a-birthday/comment-page-1/#comment-171</link>
		<dc:creator>api</dc:creator>
		<pubDate>Fri, 11 Apr 2008 14:29:33 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanng.com/2008/01/28/calculate-age-in-rails-with-a-birthday/#comment-171</guid>
		<description>( (Date.today - birthday).to_i / 365.25).floor this will work with leap-year</description>
		<content:encoded><![CDATA[<p>( (Date.today &#8211; birthday).to_i / 365.25).floor this will work with leap-year</p>
]]></content:encoded>
	</item>
</channel>
</rss>

