summaryrefslogtreecommitdiffstats
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
commit0d0095a5386b1abc1678a00ddf6633af4290cfb8 (patch)
treea1843c45a65e1050416769821b4fa8eb3c5cc07e /strftime.c
parentad40af58af0f487e0230b6ec0f36b261360b7ba8 (diff)
downloadruby-0d0095a5386b1abc1678a00ddf6633af4290cfb8.tar.gz
ruby-0d0095a5386b1abc1678a00ddf6633af4290cfb8.tar.xz
ruby-0d0095a5386b1abc1678a00ddf6633af4290cfb8.zip
* 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: http://svn.ruby-lang.org/repos/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 addfe6b86..6ad74de08 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