From 2199c85dd6eb6f912bf4502ceca27da1933e9d71 Mon Sep 17 00:00:00 2001 From: tadf Date: Sat, 26 May 2012 09:16:26 +0000 Subject: * 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 --- ext/date/date_strftime.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) (limited to 'ext/date') diff --git a/ext/date/date_strftime.c b/ext/date/date_strftime.c index 1572e383c1..4236666fa6 100644 --- a/ext/date/date_strftime.c +++ b/ext/date/date_strftime.c @@ -228,8 +228,9 @@ date_strftime_with_tmx(char *s, size_t maxsize, const char *format, continue; 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)) { long y = FIX2LONG(year); 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; 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); continue; @@ -402,24 +404,6 @@ date_strftime_with_tmx(char *s, size_t maxsize, const char *format, STRFTIME("%m/%d/%y"); 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 */ if (flags & BIT_OF(CHCASE)) { flags &= ~(BIT_OF(UPPER) | BIT_OF(CHCASE)); -- cgit v1.2.3