Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: (No subject)Date: Thu, 31 Jan 2002 12:42:57 -0700

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"