summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 504224197d..f5243349cc 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 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));