1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

merge revision(s) 35366,35377,35399,35406:

* strftime.c (rb_strftime_with_timespec): fix padding of time zone
	  offset.  [ruby-dev:43287][Bug #4458]

	* strftime.c (rb_strftime_with_timespec): add an interim digit for
	  the timezone offset which is less than an hour.

	* strftime.c (rb_strftime_with_timespec): fix carry-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/branches/ruby_1_9_3@35416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2012-04-20 22:16:21 +00:00
parent eaa1fccf1d
commit a834d7fe61
4 changed files with 57 additions and 6 deletions

View file

@ -1,3 +1,15 @@
Sat Apr 21 07:16:16 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* strftime.c (rb_strftime_with_timespec): fix padding of time zone
offset. [ruby-dev:43287][Bug #4458]
* strftime.c (rb_strftime_with_timespec): add an interim digit for
the timezone offset which is less than an hour.
* strftime.c (rb_strftime_with_timespec): fix carry-up bug and
overwrite '+' with '-' if negative offset less than a hour.
[ruby-core:44447][Bug #6323]
Fri Apr 20 12:30:06 2012 Eric Hodel <drbrain@segment7.net>
* lib/rubygems/ssl_certs/AddTrustExternalCARoot.pem: Removed to avoid

View file

@ -182,6 +182,9 @@ rb_strftime_with_timespec(char *s, size_t maxsize, const char *format, const str
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] = {
@ -473,12 +476,16 @@ rb_strftime_with_timespec(char *s, size_t maxsize, const char *format, const str
}
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;
if (sign < 0 && off < 3600) {
*(padding == ' ' ? s + i - 2 : s) = '-';
}
s += i;
off = off % 3600;
if (1 <= colons)

View file

@ -659,6 +659,38 @@ class TestTime < Test::Unit::TestCase
bug4457 = '[ruby-dev:43285]'
assert_raise(Errno::ERANGE, bug4457) {Time.now.strftime('%8192z')}
bug4458 = '[ruby-dev:43287]'
t = T2000.getlocal("+09:00")
assert_equal(" +900", t.strftime("%_10z"), bug4458)
assert_equal("+000000900", t.strftime("%10z"), bug4458)
assert_equal(" +9:00", t.strftime("%_:10z"), bug4458)
assert_equal("+000009:00", t.strftime("%:10z"), bug4458)
assert_equal(" +9:00:00", t.strftime("%_::10z"), bug4458)
assert_equal("+009:00:00", t.strftime("%::10z"), bug4458)
t = T2000.getlocal("-05:00")
assert_equal(" -500", t.strftime("%_10z"), bug4458)
assert_equal("-000000500", t.strftime("%10z"), bug4458)
assert_equal(" -5:00", t.strftime("%_:10z"), bug4458)
assert_equal("-000005:00", t.strftime("%:10z"), bug4458)
assert_equal(" -5:00:00", t.strftime("%_::10z"), bug4458)
assert_equal("-005:00:00", t.strftime("%::10z"), bug4458)
bug6323 = '[ruby-core:44447]'
t = T2000.getlocal("+00:36")
assert_equal(" +036", t.strftime("%_10z"), bug6323)
assert_equal("+000000036", t.strftime("%10z"), bug6323)
assert_equal(" +0:36", t.strftime("%_:10z"), bug6323)
assert_equal("+000000:36", t.strftime("%:10z"), bug6323)
assert_equal(" +0:36:00", t.strftime("%_::10z"), bug6323)
assert_equal("+000:36:00", t.strftime("%::10z"), bug6323)
t = T2000.getlocal("-00:55")
assert_equal(" -055", t.strftime("%_10z"), bug6323)
assert_equal("-000000055", t.strftime("%10z"), bug6323)
assert_equal(" -0:55", t.strftime("%_:10z"), bug6323)
assert_equal("-000000:55", t.strftime("%:10z"), bug6323)
assert_equal(" -0:55:00", t.strftime("%_::10z"), bug6323)
assert_equal("-000:55:00", t.strftime("%::10z"), bug6323)
end
def test_delegate

View file

@ -1,10 +1,10 @@
#define RUBY_VERSION "1.9.3"
#define RUBY_PATCHLEVEL 195
#define RUBY_PATCHLEVEL 196
#define RUBY_RELEASE_DATE "2012-04-20"
#define RUBY_RELEASE_DATE "2012-04-21"
#define RUBY_RELEASE_YEAR 2012
#define RUBY_RELEASE_MONTH 4
#define RUBY_RELEASE_DAY 20
#define RUBY_RELEASE_DAY 21
#include "ruby/version.h"