[REBOL] Re: YYYYMMDD date format
From: johnkenyon::uk::ibm::com at: 14-Nov-2000 17:31
Joel,
Thanks for the tips - I'm getting there slowly ;-)
john
8<--
Hi, Mat, John,
Here's a QAD.
zpad: func [n [number!] w [integer!] /local s] [
s: to-string n
if w > length? s [
insert/dup s "0" (w - length? s)
]
s
]
>> zpad 1 4 == "0001"
>> zpad 123 2 == "123"
It pads to the desired length, but doesn't mess up if the number already
requires more than the requested number of digits. Applying this to the
original request...
>> rejoin [zpad now/year 4 zpad now/month 2 zpad now/day 2]
== "20001114"
-jn-