Skip to content

元号のアルファベット(頭文字)表記ができると嬉しい #19

Description

@ash0411-maker

いつもありがたく使わせてもらっています!

令和4年→R4年、平成7年→H7年のように元号をアルファベット表記にできたら便利かなと思いIssueに登録しました。
これを実現するために以下のようなコードを書いているのですが、新元号になると対応できないので。。。
(もしドキュメントの確認漏れで、すでに実現可能ならすみません。)

this_year = Date.today.year
wareki_date = Date.new(this_year).to_wareki_date

case wareki_date.era_name
when "平成"
  era_name = "H"
when "令和"
  era_name = "R"
else #新元号
  era_name = ""
end

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions