On Fri, 19 Jul 2002, Andy Wardley wrote:
> On Thu, Jul 18, 2002 at 03:47:35PM -0400, darren chamberlain wrote:
> > big_number.commify(" ",5);
> >
> > Of course, we aren;t commifying any more.
>
> How about chunk(size) to turn something into chunks. Then you could
> combine with join() like so:
>
> [% big_number.chunk(3).join(',') %]
>
> No wait, numbers would need to be chunked from the right, so we could
> use a negative index for that:
>
> [% bignum = 1234567 %]
> [% bignum.chunk(-3).join(',') %] 1,234,567
> [% bignum.chunk(3).join(',') %] 123,456,7
>
> Implementation to follow...
>
> I must admit, for the common case, 'commify' is a lot simpler and
> shorter to type, so maybe we could put that in too?
Aas someone mentioned you might want to think about
internationalization.
1 234,56 FF is how you would see stuff priced on the Champs-Elysee,
$1,234.56 would be the US style of course,
1.234,56 PTA in Madrid
etc.
So I think the method needs to support language and locale preferences
(wherever and however these are set) -- ugh! -- or allow the user to
specify the chunk size, separator, etc.
My $0.02 (USD) :)
- nick
~~~~~~~~~~~~~~~~~~~~
Nick Tonkin {|8^)>