summaryrefslogtreecommitdiff
path: root/strftime.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-24 11:34:45 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-24 11:34:45 +0000
commit54370de9f4c01ba43752057b602bafc5be293665 (patch)
treea1843c45a65e1050416769821b4fa8eb3c5cc07e /strftime.c
parentdb1564ec1d48dd2e898c7ca11eed523e92c78f46 (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.c8
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