Actions
Bug #6323
closedInvalid result of Time#strftime %z
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.0.0dev (2012-04-18 trunk 35387) [i386-mswin32_100]
Backport:
Description
I guess Revision 35377 made a kind of typo.
C:>irb
irb(main):001:0> t = Time.new(2012,1,1,1,1,1,'+00:55')
=> 2012-01-01 01:01:01 +0155
irb(main):002:0> t.strftime('%z')
=> "+0155"
Here is a patch
diff --git a/strftime.c b/strftime.c.new
index ea369de..9f72777 100644
--- a/strftime.c
+++ b/strftime.c.new
@@ -493,7 +493,7 @@ 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 + 2, sign * (off / 3600 + 1)); if (i < 0) goto err; s += i - 1; off = off % 3600;
Updated by nobu (Nobuyoshi Nakada) about 12 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r35399.
Heesob, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
- 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]
Actions
Like0
Like0