diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-11-24 11:34:45 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-11-24 11:34:45 +0000 |
commit | 54370de9f4c01ba43752057b602bafc5be293665 (patch) | |
tree | a1843c45a65e1050416769821b4fa8eb3c5cc07e /strftime.c | |
parent | db1564ec1d48dd2e898c7ca11eed523e92c78f46 (diff) |
* 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
Diffstat (limited to 'strftime.c')
-rw-r--r-- | strftime.c | 8 |
1 files changed, 7 insertions, 1 deletions
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 |