Here are couple other issues encountered with
printf. This time with negative zero-padded
integers.
'%10.10d ' sprintf"_ 0 i:2
00000000-2
00000000-1
0000000000
0000000001
0000000002
'%010d ' sprintf"_ 0 i:2
-2
-1
0
1
2
Compare with C output
printf ("[%-10.10d]"), with 1234, -1234:
[0000001234]
[-0000001234]
printf ("[%010d]"), with 1234, -1234:
[0000001234]
[-000001234]
From
int main(int argc, _TCHAR* argv[]) {
printf("printf (\"%s\"), with %d, %d:\n", "[%-10.10d]", 1234,
-1234);
printf("[%-10.10d]\n[%-10.10d]\n\n", 1234, -1234);
printf("printf (\"%s\"), with %d, %d:\n", "[%010d]", 1234,
-1234);
printf("[%010d]\n[%010d]\n\n", 1234, -1234);
...
}
--- Oleg Kobchenko <[EMAIL PROTECTED]> wrote:
> ISO timestamp should be produced simpler with printf.
> However, it does not honor zero padding properly.
>
> '%04d-%02d-%02dT%02d:%02d:%02d'printf 6!:0''
> 2008- 1-20T19:18: 8
>
> So you resort to a cumbersome workaround:
>
> '%4.4d-%2.2d-%2.2dT%2.2d:%2.2d:%2.2d'printf 6!:0''
> 2008-01-20T19:17:30
>
> It was reported earlier, but nothing has been done
> since then; it was not even acknowledged.
> So a bug is filed this time.
>
> http://www.jsoftware.com/jwiki/System/Library/Bugs#printf
>
>
> --- Tom Arneson <[EMAIL PROTECTED]> wrote:
>
> > Try isotimestamp. It formats the result of 6!:0 to a fixed
> format
> >
> > load'dates'
> > isotimestamp 6!:0''
> > 2008-01-20 16:09:33.421
> >
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now.
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm