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

* ext/date/date_strftime.c: reduced the code.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35809 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
tadf 2012-05-26 09:16:26 +00:00
parent 0976f31200
commit 2199c85dd6
2 changed files with 8 additions and 20 deletions

View file

@ -1,3 +1,7 @@
Sat May 26 18:14:57 2012 Tadayoshi Funaba <tadf@dotrb.org>
* ext/date/date_strftime.c: reduced the code.
Sat May 26 18:08:59 2012 Tadayoshi Funaba <tadf@dotrb.org> Sat May 26 18:08:59 2012 Tadayoshi Funaba <tadf@dotrb.org>
* time.c: modified doc. * time.c: modified doc.

View file

@ -228,8 +228,9 @@ date_strftime_with_tmx(char *s, size_t maxsize, const char *format,
continue; continue;
case 'G': /* year of ISO week with century */ case 'G': /* year of ISO week with century */
case 'Y': /* year with century */
{ {
VALUE year = tmx_cwyear; VALUE year = (*format == 'G') ? tmx_cwyear : tmx_year;
if (FIXNUM_P(year)) { if (FIXNUM_P(year)) {
long y = FIX2LONG(year); long y = FIX2LONG(year);
FMT('0', 0 <= y ? 4 : 5, "ld", y); FMT('0', 0 <= y ? 4 : 5, "ld", y);
@ -241,7 +242,8 @@ date_strftime_with_tmx(char *s, size_t maxsize, const char *format,
continue; continue;
case 'g': /* year of ISO week without a century */ case 'g': /* year of ISO week without a century */
v = NUM2INT(mod(tmx_cwyear, INT2FIX(100))); case 'y': /* year without a century */
v = NUM2INT(mod((*format == 'g') ? tmx_cwyear : tmx_year, INT2FIX(100)));
FMT('0', 2, "d", v); FMT('0', 2, "d", v);
continue; continue;
@ -402,24 +404,6 @@ date_strftime_with_tmx(char *s, size_t maxsize, const char *format,
STRFTIME("%m/%d/%y"); STRFTIME("%m/%d/%y");
continue; continue;
case 'Y': /* year with century */
{
VALUE year = tmx_year;
if (FIXNUM_P(year)) {
long y = FIX2LONG(year);
FMT('0', 0 <= y ? 4 : 5, "ld", y);
}
else {
FMTV('0', 4, "d", year);
}
}
continue;
case 'y': /* year without a century, 00 - 99 */
v = NUM2INT(mod(tmx_year, INT2FIX(100)));
FMT('0', 2, "d", v);
continue;
case 'Z': /* time zone name or abbreviation */ case 'Z': /* time zone name or abbreviation */
if (flags & BIT_OF(CHCASE)) { if (flags & BIT_OF(CHCASE)) {
flags &= ~(BIT_OF(UPPER) | BIT_OF(CHCASE)); flags &= ~(BIT_OF(UPPER) | BIT_OF(CHCASE));