Get person's age in Ruby -
I would like to get the age of one person from my birthday now - birthday / 365 does not work Because because in some years there are 366 days I came up with the following code:
now = date date Is there any other ruby to calculate the age?
I know that I am late for the party, but the acceptable answer will be broken When one leap will try to work for the age of a person born on February 29. The reason for this is that call to birthday.to_date.change (: year => now.year) creates an invalid date .
I have the following code (in a Rail project) instead:
DEF Era (Dob) now = Time.On. NCTCTO_adet now.your-dob.yure- ((now MMTATOBMMM || (now.mm) == dob.month and now.day> gt; = dob.day )) 0: 1) End
Comments
Post a Comment