summaryrefslogtreecommitdiff
path: root/strftime.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-01-30 07:10:55 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-01-30 07:10:55 +0000
commit2418e5ca83f863b58a9e13caefc9a23414cae49c (patch)
tree7a17ed7568b11f3d56216ad93265e6793f81cf9e /strftime.c
parentb4be48e88d74c1e5cce9d68aed30c4e4ef17d7c5 (diff)
* 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
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 289f6ed48a..dc6df615d7 100644
--- a/strftime.c
+++ b/strftime.c
@@ -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));