[REBOL] Re: How to...? Convert Date of Birth to Age
From: greggirwin:mindspring at: 2-Jul-2002 17:40
<< Using Rebol (of course!), how would I convert a date of birth to an age
years, months and days? >>
Well, it's not exactly what you asked for, but it's a start. Maybe I'll mod
it later tonight.
(watch for wrap)
days-between: func [date-1[date!] date-2[date!]][
return date-1 - date-2
persons-age: func [
"Return a persons age, in years."
/precise "Include decimal portion of age."
/days "Return result as how many *days* old the person is."
/yrs-days "Return result as number of years and days (2 item block)."
/on "Use alternate date instead of current date, to figure age."
date: any [date now]
if days [return days-between date b-day]
if precise [return (days-between date b-day) / 365.25]
if yrs-days [return compose [(to-integer date - b-day / 365.25)(date -
b-day // 365.25)]]
; otherwise, take away 1 year if their birthday hasn't come yet this
return date/year - b-day/year - either any [
(date/month > b-day/month) all [
(date/month = b-day/month)(date/day >= b-day/day)]] 
persons-age/on-date 23-dec-1964 23-dec-2001