After some thought (thanks Gregg!), I came up with this:

Age: function [Date1 [date!] Date2 [date!]] [Years Months Days] [
    Years: Date1/year
    Months: Date1/month
    Days: subtract Date1/day Date2/day
    if negative? Days [
        Days: Days + pick system/locale/days-per-month Date1/month
        all [
            February? Date1
            leap-year? Date1
            Days: Days + 1
            ]
        Months: Months - 1
        ]
    Months: Months - Date2/month
    if negative? Months [
        Months: Months + 12
        Years: Years - 1
        ]
    Years: Years - Date2/year
    reduce [Years Months Days]
    ]

Which also needs this:

; This is done during Rebol's start up process.
system/locale: make system/locale [
    Days-Per-Month: [
        31    ; January
        28    ; February
        31    ; March
        30    ; April
        31    ; May
        30    ; June
        31    ; July
        31    ; August
        30    ; September
        31    ; October
        30    ; November
        31    ; December
        ]
    ]

...and this:

Leap-Year?: function [Date [date!]] [Year] [
    Year: Date/year
    any [
        all [
            0 = remainder Year 4
            0 <> remainder Year 100
            ]
        0 = remainder Year 400
        ]
    ]

But this solution, though I think it works, seems a bit too complicated.

Is there a more simpler way?

Andrew Martin
ICQ: 26227169 http://valley.150m.com/
-><-


-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to