This ir solution of mine, that I using together with round
function from library:
pad-decimal: func [ value [number!] len [integer!] /local s] [
s: form value
either len > 0 [
either all [ value = to-integer value ] [
head insert/dup tail s #"0" len - ((length? s) -
index? find s #".")
][
s: form either any [ greater? abs value 0.1 value = 0
] [
to-string value
][
replace insert to-string ( value / abs value ) +
value "0" "1." "0."
]
head insert/dup tail s #"0" len - ((length? s) -
index? find s #".")
]
][
copy/part s index? back find s "."
]
]
Janeks
On 10 Feb 2006 at 11:14, Steven White wrote:
>
> Wow! Those demos! I didn't quite realize that REBOL could do that.
> I am = mentally stuck in the days of mainframe programming when
> processors were = slow, memory was small, and interpreters were slow.
>
> But back to Dullsville, can anyone tell me how to do this?
>
> I want to assemble the year, month, and day into a string (YYYYMMDD)
> to = use in a file name. The following line almost does it:
>
> print join to-string now/year [to-string now/month to-string now/day]
>
> BUT, if the month or day is a single digit, I don't know how to pad it
> out = with a leading zero. For example, February 10, 2006 comes out
> as 2006210 = when I want 20060210.
>
> Thank you for any help.
>
>
> Steven White
> City of Bloomington
> 1800 W Old Shakopee Rd
> Bloomington MN 55431-3096
> USA
> 952-563-4882 (voice)
> 952-563-4672 (fax)
> [EMAIL PROTECTED]
>
> --
> To unsubscribe from the list, just send an email to
> lists at rebol.com with unsubscribe as the subject.
>
>
--
To unsubscribe from the list, just send an email to
lists at rebol.com with unsubscribe as the subject.