From 2418e5ca83f863b58a9e13caefc9a23414cae49c Mon Sep 17 00:00:00 2001 From: akr Date: Sun, 30 Jan 2011 07:10:55 +0000 Subject: * strftime.c (rb_strftime_with_timespec): %G produces 4 digits. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30732 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- strftime.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'strftime.c') diff --git a/strftime.c b/strftime.c index 289f6ed48a..dc6df615d7 100644 --- a/strftime.c +++ b/strftime.c @@ -613,7 +613,13 @@ rb_strftime_with_timespec(char *s, size_t maxsize, const char *format, const str yv = sub(yv, INT2FIX(1)); if (*format == 'G') { - FMTV('0', 1, "d", yv); + if (FIXNUM_P(yv)) { + long y = FIX2LONG(yv); + FMT('0', 0 <= y ? 4 : 5, "ld", y); + } + else { + FMTV('0', 4, "d", yv); + } } else { yv = mod(yv, INT2FIX(100)); -- cgit v1.2.3