1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* strftime.c (FMT): use "%0d" formatter for zero padding, not "%.d".

[ruby-dev:37168]  fix: #768

* strftime.c (rb_strftime): %s to use zero padding by default.
  [ruby-dev:37180]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20352 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2008-11-25 00:24:01 +00:00
parent 9a206a8039
commit 15b183c218
2 changed files with 10 additions and 2 deletions

View file

@ -286,7 +286,7 @@ rb_strftime(char *s, size_t maxsize, const char *format, const struct tm *timept
if (precision <= 0) precision = (def_prec); \
if (flags & BIT_OF(LEFT)) precision = 1; \
l = snprintf(s, endp - s, \
((padding == '0' || (!padding && def_pad == '0')) ? "%.*"fmt : "%*"fmt), \
((padding == '0' || (!padding && def_pad == '0')) ? "%0*"fmt : "%*"fmt), \
precision, val); \
if (l < 0) goto err; \
s += l; \
@ -417,7 +417,7 @@ rb_strftime(char *s, size_t maxsize, const char *format, const struct tm *timept
break;
case 's':
FMT(' ', 1, "d", (int) ts->tv_sec);
FMT('0', 1, "d", (int) ts->tv_sec);
continue;
case 'S': /* second, 00 - 60 */