summaryrefslogtreecommitdiff
path: root/ext/date
diff options
context:
space:
mode:
Diffstat (limited to 'ext/date')
-rw-r--r--ext/date/date_strftime.c24
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));