From 54370de9f4c01ba43752057b602bafc5be293665 Mon Sep 17 00:00:00 2001 From: akr Date: Tue, 24 Nov 2009 11:34:45 +0000 Subject: * strftime.c: %Y format a year with 4 digits at least. * lib/time.rb: format a year with 4 digits at least. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25906 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 addfe6b862..6ad74de085 100644 --- a/strftime.c +++ b/strftime.c @@ -496,7 +496,13 @@ rb_strftime(char *s, size_t maxsize, const char *format, const struct vtm *vtm, continue; case 'Y': /* year with century */ - FMTV('0', 1, "d", vtm->year); + if (FIXNUM_P(vtm->year)) { + long y = FIX2LONG(vtm->year); + FMT('0', 0 <= y ? 4 : 5, "ld", y); + } + else { + FMTV('0', 4, "d", vtm->year); + } continue; #ifdef MAILHEADER_EXT -- cgit v1.2.3