[REBOL] Interesting date formatting functions
From: AJMartin::orcon::net::nz at: 24-Dec-2003 22:50
These functions are pretty self explanatory:
DD-MM-YYYY: func [Date [date!]] [
rejoin [pad Date/day 2 #"-" pad Date/month 2 #"-" pad Date/year 4]
]
>> dd-mm-yyyy now
== "04-12-2003"
YYYYMMDD: func [Date [date!]] [
rejoin [pad Date/year 4 pad Date/month 2 pad Date/day 2]
]
>> yyyymmdd now
== "20031204"
This is the interesting one/two:
DD: make object! [
MM: make object! [
YYYY: func [Date [date!]] [
rejoin [pad Date/day 2 #"/" pad Date/month 2 #"/" pad Date/year 4]
]
]
MMM: make object! [
YYYY: func [Date [date!]] [
rejoin [pad Date/day 2 #"/" copy/part pick Rebol/locale/Months Date/month
3 #"/" pad Date/year 4]
]
]
]
>> dd/mm/yyyy now
== "04/12/2003"
>> dd/mmm/yyyy now
== "04/Dec/2003"
:) I thought they helped make it very obvious what's happening.
Enjoy!
Andrew J Martin
Speaking in tongues and performing miracles.
ICQ: 26227169
http://www.rebol.it/Valley/
http://valley.orcon.net.nz/
http://Valley.150m.com/