(No subject)Date: Thu, 31 Jan 2002 12:42:57 -0700
[1/2] from: greggirwin::mindspring::com at: 31-Jan-2002 11:34
Hi Alessandro,
Joel already answered your question, so I'll digress a bit with a really
neat bit of "locale awareness" code that Andrew Martin posted a while back.
--Gregg
;-- From Andrew Martin
use [Months Index] [
Months: system/locale/months
forall Months [
Index: index? Months system/locale/months
do reduce [
to set-word! join first Months "?" 'func [
"Is Date this month?" Date [date!]
]
reduce ['= Index 'Date/Month]
]
]
]
Month: func [Date [date!]][
pick system/locale/months Date/month
]
use [Weekdays Index] [
Weekdays: system/locale/days
forall Weekdays [
Index: index? Weekdays system/locale/days
do reduce [
to set-word! join first Weekdays "?" 'func [
"Is Date this weekday?" Date [date!]
]
reduce ['= Index 'Date/weekday]
]
]
]
Weekday: func [Date [date!]][
pick system/locale/days Date/weekday
]
;-- Sample results
>> now
== 27-Sep-2001/18:43:41+12:00
>> september? now
== true
>> month now
== "September"
>> thursday? now
== true
>> weekday now
== "Thursday"
[2/2] from: al:bri:xtra at: 1-Feb-2002 17:18
> Joel already answered your question, so I'll digress a bit with a really
neat bit of "locale awareness" code that Andrew Martin posted a while back.
Thanks, Gregg!
It's available online at:
http://valley.150m.com/Rebol/Values/Month.r
and:
http://valley.150m.com/Rebol/Values/Weekday.r
Andrew Martin
[] not []]! :-O
ICQ: 26227169 http://valley.150m.com/