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

trivial changes

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35647 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
tadf 2012-05-14 21:39:25 +00:00
parent 3e972bbaba
commit b6de661b54
2 changed files with 25 additions and 21 deletions

View file

@ -1,6 +1,6 @@
/*
date_strftime.c: based on a public-domain implementation of ANSI C
library routine of strftime, which is originally written by Arnold
library routine strftime, which is originally written by Arnold
Robbins.
*/
@ -84,7 +84,8 @@ date_strftime_with_tmx(char *s, size_t maxsize, const char *format,
if (precision <= 0) precision = (def_prec); \
if (flags & BIT_OF(LEFT)) precision = 1; \
l = snprintf(s, endp - s, \
((padding == '0' || (!padding && (def_pad) == '0')) ? "%0*"fmt : "%*"fmt), \
((padding == '0' || (!padding && (def_pad) == '0')) ? \
"%0*"fmt : "%*"fmt), \
precision, (val)); \
if (l < 0) goto err; \
s += l; \
@ -183,7 +184,7 @@ date_strftime_with_tmx(char *s, size_t maxsize, const char *format,
}
break;
case 'C':
case 'C': /* century (year/100) */
FMTV('0', 2, "d", div(tmx_year, INT2FIX(100)));
continue;
@ -272,7 +273,8 @@ date_strftime_with_tmx(char *s, size_t maxsize, const char *format,
subsec = div(subsec, INT2FIX(1));
if (FIXNUM_P(subsec)) {
(void)snprintf(s, endp - s, "%0*ld", precision, FIX2LONG(subsec));
(void)snprintf(s, endp - s, "%0*ld",
precision, FIX2LONG(subsec));
s += precision;
}
else {
@ -321,7 +323,7 @@ date_strftime_with_tmx(char *s, size_t maxsize, const char *format,
i = 2;
break;
case 'Q':
case 'Q': /* microseconds since Unix epoch */
FMTV('0', 1, "d", tmx_msecs);
continue;
@ -338,7 +340,7 @@ date_strftime_with_tmx(char *s, size_t maxsize, const char *format,
FMT('0', 2, "d", v);
continue;
case 's':
case 's': /* seconds since Unix epoch */
FMTV('0', 1, "d", tmx_secs);
continue;
@ -352,8 +354,7 @@ date_strftime_with_tmx(char *s, size_t maxsize, const char *format,
FMT('0', 2, "d", v);
continue;
case 'u':
/* ISO 8601: Weekday as a decimal number [1 (Monday) - 7] */
case 'u': /* weekday, Monday == 1, 1 - 7 */
v = range(1, tmx_cwday, 7);
FMT('0', 1, "d", v);
continue;
@ -413,7 +414,7 @@ date_strftime_with_tmx(char *s, size_t maxsize, const char *format,
}
break;
case 'z': /* time zone offset east of UTC e.g. -0600 */
case 'z': /* offset from UTC */
{
long off, aoff;
int hl, hw;
@ -451,15 +452,18 @@ date_strftime_with_tmx(char *s, size_t maxsize, const char *format,
case 3: /* %:::z -> +hh[:mm[:ss]] */
{
if (aoff % 3600 == 0) {
precision = precision <= (1 + hw) ? hw : precision-1;
precision = precision <= (1 + hw) ?
hw : precision - 1;
NEEDS(precision + 3);
}
else if (aoff % 60 == 0) {
precision = precision <= (4 + hw) ? hw : precision-4;
precision = precision <= (4 + hw) ?
hw : precision - 4;
NEEDS(precision + 4);
}
else {
precision = precision <= (7 + hw) ? hw : precision-7;
precision = precision <= (7 + hw) ?
hw : precision - 7;
NEEDS(precision + 7);
}
}