[REBOL] Re: YYYYMMDD date format
From: joel:neely:fedex at: 14-Nov-2000 10:16
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-
[rebol-bounce--rebol--com] wrote:
> Heya johnkenyon,
>
> juic> Hi,
>
> juic> now/month returns 1 not 01 for month in Jan so ..
>
> juic> nowdate: rejoin [ now/year either now/month < 10 [ "0" ] [ "" ] now/month
> juic> now/day ]
>
> Mmmm, that's interesting. I bet you could use that to make a VASTLY
> more elegant solution to my rather disgusting hack to generate some
> serial numbers with padded zeros.
>
> How could you extend that for a 3 digit issue?
>
> IE
>
> 0-9
> 10-99
> 100-999
>
> I'd show you how I did it but it's really quite embarrassing ;)
>
> The only thing that really annoys me in rebol is simple high level
> string handling really. The Amigas Arexx had such easy ways to do this
> sort of thing - in fact so did BASIC even.
>
> Tell you something else I'd give my left one for, a straight port of
> the Arexx parse command. I don't think I'll *ever* understand Rebols
> :(
>
> --
> Mat Bettinson - EuroGamer's Gaming Evangelist with a Goatee
> http://www.eurogamer.net | http://www.eurogamer-network.com
>
> --
> To unsubscribe from this list, please send an email to
> [rebol-request--rebol--com] with "unsubscribe" in the
> subject, without the quotes.
--
; Joel Neely [joel--neely--fedex--com] 901-263-4460 38017/HKA/9677
REBOL [] foreach [order string] sort/skip reduce [ true "!"
false head reverse "rekcah" none "REBOL " prin "Just " "another "
] 2 [prin string] print ""