Project

General

Profile

Actions

Bug #18514

closed

ruby 2.6.9's Date#jisx0301 does not support Reiwa

Added by kouji (Kouji Takao) about 2 years ago. Updated about 2 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 2.6.9p207 (2021-11-24 revision 67954) [x86_64-darwin20]
[ruby-core:107280]

Description

In ruby 2.6.9 (ruby 2.6.9p207 (2021-11-24 revision 67954) [x86_64-darwin20]).
$ ruby -rdate -e 'p Date.new(2019, 5, 1).jisx0301'
=> "H31.05.01"

In ruby 2.6.6 and 2.7.5.
=> "R01.05.01"

ruby 2.6.9's Date#jisx0301does not support Reiwa.
https://github.com/ruby/ruby/blob/8e26731f9ef529009928628ba4b79fd2454e8e2d/ext/date/date_core.c#L7193

However, ruby 2.6.8's supports Reiwa.
https://github.com/ruby/ruby/blob/768423edc2634574d66f14f3c2d3602326bfb464/ext/date/date_core.c#L7046

diff

--- 2.6.8.c     2022-01-26 10:42:49.000000000 +0900
+++ 2.6.9.c     2022-01-26 10:43:57.000000000 +0900
@@ -19,14 +19,10 @@
            c = 'S';
            s = 1925;
     }
-    else if (d < 2458605) {
+    else {
            c = 'H';
            s = 1988;
     }
-    else {
-           c = 'R';
-           s = 2018;
-    }
     snprintf(fmt, size, "%c%02ld" ".%%m.%%d", c, FIX2INT(y) - s);
     return fmt;
   }

So, I think it's a degradation.

Actions #1

Updated by usa (Usaku NAKAMURA) about 2 years ago

  • Status changed from Open to Closed
  • Backport changed from 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN to 2.6: REQUIRED, 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
Actions #2

Updated by hsbt (Hiroshi SHIBATA) about 2 years ago

  • Assignee set to hsbt (Hiroshi SHIBATA)

Updated by hsbt (Hiroshi SHIBATA) about 2 years ago

I prepared to fix this regression.

https://github.com/ruby/date/pull/47

I will release date-2.0.3 for Ruby 2.6 in a few days.

Actions #4

Updated by hsbt (Hiroshi SHIBATA) about 2 years ago

I released date-2.0.3 with Reiwa support.

@kouji (Kouji Takao) Can you confirm with date-2.0.3 ?

After that, I will create backport patch for Ruby 2.6.10.

Updated by kouji (Kouji Takao) about 2 years ago

Can you confirm with date-2.0.3 ?

Thank you so much.
I tried it, then I get good result!

Updated by hsbt (Hiroshi SHIBATA) about 2 years ago

  • Assignee changed from hsbt (Hiroshi SHIBATA) to usa (Usaku NAKAMURA)
  • Backport changed from 2.6: REQUIRED, 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN to 2.6: REQUIRED, 2.7: DONTNEED, 3.0: DONTNEED, 3.1: DONTNEED
Actions #8

Updated by usa (Usaku NAKAMURA) about 2 years ago

  • Backport changed from 2.6: REQUIRED, 2.7: DONTNEED, 3.0: DONTNEED, 3.1: DONTNEED to 2.6: DONE, 2.7: DONTNEED, 3.0: DONTNEED, 3.1: DONTNEED
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0