Project

General

Profile

Bug #4458 » patch3.diff

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

View differences:

strftime.c
459 459
		case 'z':	/* time zone offset east of GMT e.g. -0600 */
460 460
                        switch (colons) {
461 461
                          case 0: /* %z -> +hhmm */
462
                            precision = precision <= 5 ? 2 : precision-3;
463
                            NEEDS(precision + 3);
462
                            precision = precision <= 5 ? 0 : precision-5;
463
                            NEEDS(precision + 5);
464 464
                            break;
465 465

  
466 466
                          case 1: /* %:z -> +hh:mm */
467
                            precision = precision <= 6 ? 2 : precision-4;
468
                            NEEDS(precision + 4);
467
                            precision = precision <= 6 ? 0 : precision-6;
468
                            NEEDS(precision + 6);
469 469
                            break;
470 470

  
471 471
                          case 2: /* %::z -> +hh:mm:ss */
472
                            precision = precision <= 9 ? 2 : precision-7;
473
                            NEEDS(precision + 7);
472
                            precision = precision <= 9 ? 0 : precision-9;
473
                            NEEDS(precision + 9);
474 474
                            break;
475 475

  
476 476
                          default:
......
483 483
			else {
484 484
				off = NUM2LONG(rb_funcall(vtm->utc_offset, rb_intern("round"), 0));
485 485
			}
486
			for (i = 0; i < precision; i++)
487
			    *s++ = padding == ' ' ? padding : '0';
486 488
			if (off < 0) {
487 489
				off = -off;
488 490
				*s++ = '-';
489 491
			} else {
490 492
				*s++ = '+';
491 493
			}
492
			i = snprintf(s, endp - s, (padding == ' ' ? "%*ld" : "%.*ld"), precision, off / 3600);
494
			i = snprintf(s, endp - s, (padding == ' ' ? "%2ld" : "%.2ld"), off / 3600);
493 495
			if (i < 0) goto err;
494 496
			s += i;
495 497
                        off = off % 3600;