summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-05-26 09:16:26 +0000
committertadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-05-26 09:16:26 +0000
commit2199c85dd6eb6f912bf4502ceca27da1933e9d71 (patch)
tree8c316d3ce7662ae214b51e8631c877ace422ad0e
parent0976f312003c322db8a602dfd8e02ababdafa486 (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
-rw-r--r--ChangeLog4
-rw-r--r--ext/date/date_strftime.c24
2 files changed, 8 insertions, 20 deletions
diff --git a/ChangeLog b/ChangeLog
index 504224197db..f5243349cc3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
* time.c: modified doc.
diff --git a/ext/date/date_strftime.c b/ext/date/date_strftime.c
index 1572e383c1c..4236666fa63 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));