diff --git a/ChangeLog b/ChangeLog index 4841d08e4f..abd6d35693 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Thu Aug 28 23:55:50 2008 Shugo Maeda + + * strftime.c (rb_strftime): Time.mktime(2000).strftime("%-S") should + return "0", not "". + + * test/ruby/test_time.rb: ditto. + Thu Aug 28 23:55:22 2008 Yusuke Endoh * test/ruby/test_time.rb: suppress warning during test. diff --git a/strftime.c b/strftime.c index d90e8e5267..2b8033cf28 100644 --- a/strftime.c +++ b/strftime.c @@ -275,7 +275,7 @@ rb_strftime(char *s, size_t maxsize, const char *format, const struct tm *timept do { \ int l; \ if (precision <= 0) precision = (def_prec); \ - if (flags & BIT_OF(LEFT)) precision = 0; \ + if (flags & BIT_OF(LEFT)) precision = 1; \ l = snprintf(s, endp - s, \ ((!padding || padding == (def_pad)) ? "%.*"fmt : "%*"fmt), \ precision, val); \ diff --git a/test/ruby/test_time.rb b/test/ruby/test_time.rb index 4378e6ff14..237721c4db 100644 --- a/test/ruby/test_time.rb +++ b/test/ruby/test_time.rb @@ -382,6 +382,7 @@ class TestTime < Test::Unit::TestCase assert_equal("2000", T2000.strftime("%Y")) assert_equal("UTC", T2000.strftime("%Z")) assert_equal("%", T2000.strftime("%%")) + assert_equal("0", T2000.strftime("%-S")) assert_equal("", T2000.strftime("")) assert_equal("foo\0bar\x0000\x0000\x0000", T2000.strftime("foo\0bar\0%H\0%M\0%S"))