aboutsummaryrefslogtreecommitdiffstats
path: root/strftime.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-04-19 07:33:55 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-04-19 07:33:55 +0000
commite0ffb9b59be89bc0434ebeacafa2bb0160306423 (patch)
treee8dd4a1ca07f9d71565fe58c958cd37d11acb1d5 /strftime.c
parentec0bd633e274544391d5f7899d0bfd5b7c63f872 (diff)
downloadruby-e0ffb9b59be89bc0434ebeacafa2bb0160306423.tar.gz
* strftime.c (rb_strftime_with_timespec): fix carrir-up bug and
overwrite '+' with '-' if negative offset less than a hour. [ruby-core:44447][Bug #6323] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35399 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'strftime.c')
-rw-r--r--strftime.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/strftime.c b/strftime.c
index ea369deaa0..8be95a310b 100644
--- a/strftime.c
+++ b/strftime.c
@@ -493,9 +493,12 @@ rb_strftime_with_timespec(char *s, size_t maxsize, const char *format, rb_encodi
sign = +1;
}
i = snprintf(s, endp - s, (padding == ' ' ? "%+*ld" : "%+.*ld"),
- precision + 2, sign * (off / 360 + 1));
+ precision + 1, sign * (off / 3600));
if (i < 0) goto err;
- s += i - 1;
+ if (sign < 0 && off < 3600) {
+ *(padding == ' ' ? s + i - 2 : s) = '-';
+ }
+ s += i;
off = off % 3600;
if (1 <= colons)
*s++ = ':';