diff options
author | tadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-05-26 09:16:26 +0000 |
---|---|---|
committer | tadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-05-26 09:16:26 +0000 |
commit | 2199c85dd6eb6f912bf4502ceca27da1933e9d71 (patch) | |
tree | 8c316d3ce7662ae214b51e8631c877ace422ad0e /ext/date/date_strftime.c | |
parent | 0976f312003c322db8a602dfd8e02ababdafa486 (diff) |
* 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
Diffstat (limited to 'ext/date/date_strftime.c')
-rw-r--r-- | ext/date/date_strftime.c | 24 |
1 files changed, 4 insertions, 20 deletions
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)); |