Project

General

Profile

Actions

Feature #15742

closed

Add Date#jisx0301 support new Japanese era

Added by kaishuu0123 (Koki Oyatsu) over 5 years ago. Updated over 5 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:92071]

Description

Reproduce process

irb(main):002:0> require 'date'
=> true
irb(main):003:0> Date.new(2019, 5, 1).jisx0301
=> "H31.05.01"
  • ruby version: trunk

Result of reproduce process

irb(main):003:0> Date.new(2019, 5, 1).jisx0301
=> "H31.05.01"

Expected result and the reason why you expect

irb(main):002:0> require 'date'
=> true
irb(main):003:0> Date.new(2019, 5, 1).jisx0301
=> "R01.05.01"

reason


Related issues 2 (0 open2 closed)

Related to Ruby master - Feature #15195: Deal with new Japanese eraClosedduerst (Martin Dürst)Actions
Blocks Ruby master - Bug #15740: Backport Unicode Version 12.1.0 and other Japanese new era issues to Ruby 2.6Closednaruse (Yui NARUSE)Actions
Actions #1

Updated by kaishuu0123 (Koki Oyatsu) over 5 years ago

  • Description updated (diff)

Updated by mame (Yusuke Endoh) over 5 years ago

  • Status changed from Open to Feedback

Thanks, that's good to know. However, we should wait for the new revision of JIS X 0301. Could you let us know if the spec is actually revised?

Updated by znz (Kazuhiro NISHIYAMA) over 5 years ago

It seems Date.jisx0301 supports Japanese era too.

Actions #4

Updated by duerst (Martin Dürst) over 5 years ago

Actions #5

Updated by duerst (Martin Dürst) over 5 years ago

  • Blocks Bug #15740: Backport Unicode Version 12.1.0 and other Japanese new era issues to Ruby 2.6 added

Updated by duerst (Martin Dürst) over 5 years ago

kaishuu0123 (Koki Oyatsu) wrote:

I'm also not 100% sure the new letter will be "R", but given that all major Romanization methods
(https://en.wikipedia.org/wiki/Hepburn_romanization, https://en.wikipedia.org/wiki/Kunrei-shiki_romanization, and https://en.wikipedia.org/wiki/Nihon-shiki_romanization) use 'R' and not 'L', and "ei" and "wa" are already established from Heisei and Showa, I'd bet quite a bit that it's Reiwa and 'R', and not something else.

Updated by nobu (Nobuyoshi Nakada) over 5 years ago

znz (Kazuhiro NISHIYAMA) wrote:

It seems Date.jisx0301 supports Japanese era too.

It defaults to Heisei if no era initial letter is found.
I guess it probably would be expected to the new era now, but it is an incompatibility of course.

Updated by duerst (Martin Dürst) over 5 years ago

nobu (Nobuyoshi Nakada) wrote:

It defaults to Heisei if no era initial letter is found.
I guess it probably would be expected to the new era now, but it is an incompatibility of course.

Yes, incompatibilities like this are unavoidable with a date system such as the Japanese era names.

Updated by duerst (Martin Dürst) over 5 years ago

mame (Yusuke Endoh) wrote:

Thanks, that's good to know. However, we should wait for the new revision of JIS X 0301. Could you let us know if the spec is actually revised?

It may be that the spec is revised, but this usually takes quite some time. I'd personally suggest we move ahead so that this new functionality can be used as soon as possible in Ruby.

Updated by nobu (Nobuyoshi Nakada) over 5 years ago

Considering Heisei is just 30years, omission of era can cause deadly confusions now and coming decades.
I think it should be an error, rather than assuming the latest era.

Updated by kaishuu0123 (Koki Oyatsu) over 5 years ago

Considering Heisei is just 30years, omission of era can cause deadly confusions now and coming decades.

(As a premise, difficult to dicard current spec.)

I was surprised that handled the omission of era in Date#jisx0301.
Because I think that it is better not to incorporate features specific to a specific country.
Basically, I think Date#jisx0301 may be added by gem.

Updated by nobu (Nobuyoshi Nakada) over 5 years ago

kaishuu0123 (Koki Oyatsu) wrote:

I was surprised that handled the omission of era in Date#jisx0301.

More surprisingly, it is required by JIS X 0301; its definition is basically non-era, and the era may be preceded.

必要によっては、年の表示の前に元号を識別する記号を付けてもよい。
If necessary, the year display may be preceded by a symbol identifying the era.

(translated by google)

Because I think that it is better not to incorporate features specific to a specific country.
Basically, I think Date#jisx0301 may be added by gem.

Totally agree, but not only the particular methods, a kitchen-sink Date.parse also incorporates the feature.

Updated by nobu (Nobuyoshi Nakada) over 5 years ago

  • Tracker changed from Misc to Feature

nobu (Nobuyoshi Nakada) wrote:

kaishuu0123 (Koki Oyatsu) wrote:

I was surprised that handled the omission of era in Date#jisx0301.

More surprisingly, it is required by JIS X 0301; its definition is basically non-era, and the era may be preceded.

必要によっては、年の表示の前に元号を識別する記号を付けてもよい。
If necessary, the year display may be preceded by a symbol identifying the era.

Note: JIS X 0301 states the era symbol is optional, but doesn't mention the default era in the case it is omitted.
At the best, it will be defined by the application(s), I guess, like announcers in ISO/IEC 2022.

Updated by duerst (Martin Dürst) over 5 years ago

nobu (Nobuyoshi Nakada) wrote:

Note: JIS X 0301 states the era symbol is optional, but doesn't mention the default era in the case it is omitted.
At the best, it will be defined by the application(s), I guess, like announcers in ISO/IEC 2022.

It's a sign that the committee responsible for JIS X 0301 wasn't able to agree, or didn't have any really good idea how it would work, or both. Essentially, it's similar to the Y2K problem, except it occurs more often.

Updated by akr (Akira Tanaka) over 5 years ago

nobu (Nobuyoshi Nakada) wrote:

Note: JIS X 0301 states the era symbol is optional, but doesn't mention the default era in the case it is omitted.
At the best, it will be defined by the application(s), I guess, like announcers in ISO/IEC 2022.

JIS X 0301:2002 is a Japanese translation of ISO 8601:2000 with era-description.

I think no-era representation is similar to truncation of ISO 8601:2000.
"truncation" provides a way to omit higher order component by mutual agreement:
describe the year 1985 as 85 for example.
(See Wikipedia https://en.wikipedia.org/wiki/ISO_8601#Truncated_representations )

I think no-era representation should also be interpreted by a mutual agreement.
In Ruby context, the agreement should be represented by the reference manual.
Unfortunately, the manual is not clear.
The manual of Date.jisx0301 describes the format as just "some typical JIS X 0301 formats"

Apart from that, "truncation" is removed at ISO 8601:2004.
So, it is reasonable to consider no-era representation as legacy feature.
(I don't know the future version of JIS X 0301, though.)

My idea:

  • Document Date.jisx0301 interpret no-era representation as Heisei.
    This is appropriate because it is a legacy feature.
    And this is compatible as current version.
  • Support "R" for Reiwa.
    I think the initial letter R is almost fixed and no-one lose with it.

Updated by rrroybbbean (RRRoy BBBean) over 5 years ago

Can this be handled like thread exceptions?

Thread.abort_on_exception=true

I like this approach because it's dynamic and changes the behavior for
the current runtime.

Date.japanese_era_exception=true

Or perhaps something like Firefox about:config

Runtime.thread.abort_on_exception = true
Runtime.date.japanese.era_exception = true

Updated by nobu (Nobuyoshi Nakada) over 5 years ago

akr (Akira Tanaka) wrote:

I think no-era representation is similar to truncation of ISO 8601:2000.
"truncation" provides a way to omit higher order component by mutual agreement:
describe the year 1985 as 85 for example.
(See Wikipedia https://en.wikipedia.org/wiki/ISO_8601#Truncated_representations )

It reminds me the second parameter to Time.parse:

We can change the date used to infer our missing elements by passing a
second object that responds to #mon, #day and #year, such as Date, Time
or DateTime.

Apart from that, "truncation" is removed at ISO 8601:2004.

Good to know it.

So, it is reasonable to consider no-era representation as legacy feature.
(I don't know the future version of JIS X 0301, though.)

Maybe, we should await next JIS X 0301?

My idea:

  • Document Date.jisx0301 interpret no-era representation as Heisei.
    This is appropriate because it is a legacy feature.
    And this is compatible as current version.
  • Support "R" for Reiwa.
    I think the initial letter R is almost fixed and no-one lose with it.

Patches updated.

Updated by akr (Akira Tanaka) over 5 years ago

nobu (Nobuyoshi Nakada) wrote:

Maybe, we should await next JIS X 0301?

I think it is too late.
JIS X 0301 update schedule is not shown.

However, we can wait vendors such as Microsoft.
Microsoft also needs the single letter abbreviation of Reiwa.

I hope some guideline including the abbreviation will appear.

Patches updated.

You missed URL.
I found: https://github.com/nobu/ruby/tree/feature/japanese-reiwa

Updated by nobu (Nobuyoshi Nakada) over 5 years ago

akr (Akira Tanaka) wrote:

Maybe, we should await next JIS X 0301?

I think it is too late.
JIS X 0301 update schedule is not shown.

As Japanese government has claimed that only one month is enough for the transition, the new standard will be issued in this month at latest :)

Actions #22

Updated by nobu (Nobuyoshi Nakada) over 5 years ago

  • Status changed from Feedback to Closed

Applied in changeset trunk|r67474.


date: support for Reiwa, new Japanese era

[Feature #15742]

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0