* 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
This commit is contained in:
akr 2011-01-30 07:10:55 +00:00
parent b4be48e88d
commit 2418e5ca83
3 changed files with 23 additions and 1 deletions

View file

@ -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));