Project

General

Profile

Bug #4458 » patch2.diff

Glass_saga (Masaki Matsushita), 04/17/2012 12:29 AM

View differences:

strftime.c
case 'z': /* time zone offset east of GMT e.g. -0600 */
switch (colons) {
case 0: /* %z -> +hhmm */
precision = precision <= 5 ? 2 : precision-3;
NEEDS(precision + 3);
precision = precision <= 5 ? 0 : precision-5;
NEEDS(precision + 5);
break;
case 1: /* %:z -> +hh:mm */
precision = precision <= 6 ? 2 : precision-4;
NEEDS(precision + 4);
precision = precision <= 6 ? 0 : precision-6;
NEEDS(precision + 6);
break;
case 2: /* %::z -> +hh:mm:ss */
precision = precision <= 9 ? 2 : precision-7;
NEEDS(precision + 7);
precision = precision <= 9 ? 0 : precision-9;
NEEDS(precision + 9);
break;
default:
......
else {
off = NUM2LONG(rb_funcall(vtm->utc_offset, rb_intern("round"), 0));
}
for (i = 0; i < precision; i++)
*s++ = padding;
if (off < 0) {
off = -off;
*s++ = '-';
} else {
*s++ = '+';
}
i = snprintf(s, endp - s, (padding == ' ' ? "%*ld" : "%.*ld"), precision, off / 3600);
i = snprintf(s, endp - s, (padding == ' ' ? "%2ld" : "%.2ld"), off / 3600);
if (i < 0) goto err;
s += i;
off = off % 3600;
(2-2/3)