summaryrefslogtreecommitdiff
path: root/strftime.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-04-17 13:18:51 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-04-17 13:18:51 +0000
commit43dbbefbdf9cf46933bb4c24929de9e8b1a66429 (patch)
tree81e02f1467662dfdb867c84002b1770dbf6a0e8a /strftime.c
parent77321aeed941c7fd2e09c881e636562440217511 (diff)
* strftime.c (rb_strftime_with_timespec): fix padding of time zone
offset. [ruby-dev:43287][Bug #4458] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35366 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'strftime.c')
-rw-r--r--strftime.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/strftime.c b/strftime.c
index b02c482d3b..3a50e55fbd 100644
--- a/strftime.c
+++ b/strftime.c
@@ -189,6 +189,9 @@ rb_strftime_with_timespec(char *s, size_t maxsize, const char *format, rb_encodi
char padding;
enum {LEFT, CHCASE, LOWER, UPPER, LOCALE_O, LOCALE_E};
#define BIT_OF(n) (1U<<(n))
+#ifdef MAILHEADER_EXT
+ int sign;
+#endif
/* various tables, useful in North America */
static const char days_l[][10] = {
@@ -485,11 +488,12 @@ rb_strftime_with_timespec(char *s, size_t maxsize, const char *format, rb_encodi
}
if (off < 0) {
off = -off;
- *s++ = '-';
+ sign = -1;
} else {
- *s++ = '+';
+ sign = +1;
}
- i = snprintf(s, endp - s, (padding == ' ' ? "%*ld" : "%.*ld"), precision, off / 3600);
+ i = snprintf(s, endp - s, (padding == ' ' ? "%+*ld" : "%+.*ld"),
+ precision + 1, sign * (off / 3600));
if (i < 0) goto err;
s += i;
off = off % 3600;