Make the %s format (seconds since the epoch) work for a negative
authorJim Meyering <jim@meyering.net>
Fri, 19 Aug 2005 09:21:57 +0000 (09:21 +0000)
committerJim Meyering <jim@meyering.net>
Fri, 19 Aug 2005 09:21:57 +0000 (09:21 +0000)
number and when used with a zero-padded field width, e.g. %015s.

(my_strftime): Move the `do_number_sign_and_padding'
label so that it precedes the code to set `digits'.  Otherwise,
%0Ns wouldn't work.  Before this change, `date -d @-22 +%05s' would
print `00-22'.  Now, it prints `-0022', as it should.

lib/strftime.c

index fb7354efd256691cb655975c22a3a608f284c41a..b68b4cf5addfabcd45ce41b06f95f9ae08eedfc5 100644 (file)
@@ -909,10 +909,10 @@ my_strftime (CHAR_T *s, size_t maxsize, const CHAR_T *format,
            }
          while (u_number_value != 0);
 
+       do_number_sign_and_padding:
          if (digits < width)
            digits = width;
 
-       do_number_sign_and_padding:
          if (negative_number)
            *--bufp = L_('-');