Upgrade to Pro — share decks privately, control downloads, hide ads and more …

From ㍻ to U+32FF

MITSUMITSU
April 19, 2019

From ㍻ to U+32FF

@RubyKaigi 2019

MITSUMITSU

April 19, 2019
Tweet

More Decks by MITSUMITSU

Other Decks in Technology

Transcript

  1. From ㍻ to U+32FF
    From ㍻ to U+32FF
    From ㍻ to U+32FF
    From ㍻ to U+32FF
    MITSUBOSHI Yuya

    View Slide

  2. From ㍻ to U+32FF
    From ㍻ to U+32FF
    From ㍻ to U+32FF
    From ㍻ to
    MITSUBOSHI Yuya

    View Slide

  3. Self-Introduction
    MITSUBOSHI Yuya (三星祐也)
    - GitHub: @MITSUBOSHI
    - Twitter: @Y_MITSUBOSHI
    - Working for Money Forward, inc.
    - Born in Heisei (平成) 5

    View Slide

  4. 2019 is a Big Year for Accounting Software in Japan
    - Change of Gengo (Japanese Era Name)
    - 平成(Heisei) -> 令和(Reiwa)
    - From 2019/05: less than half a month left
    - Change of Consumption Tax Rate
    - 8% -> 10% and multiple tax rates (+ reduced tax rate) will be introduced
    - From 2019/10: still more than 5 months left

    View Slide

  5. What gengo is
    *quoted from wikipedia

    View Slide

  6. What gengo is: briefly
    - Gengo is one of the year numbering system
    used in Japan
    - It is convertible to Christian Era (Heisei 31 -> 2019)
    - Gengo changes when the Emperor changes

    View Slide

  7. Schedule
    New Japanese era name Announced
    April May
    Golden Week
    1st 27 6
    18 20
    RubyKaigi 2019
    Reiwa (令和)
    Heisei (平成)

    View Slide

  8. How our system use Japanese era
    2019

    View Slide

  9. How our system use Japanese era
    2019
    Tax
    Office

    View Slide

  10. How our system use Japanese era
    2019
    Tax
    Office
    平成31

    View Slide

  11. How our system use Japanese era
    Bank
    Other
    Company
    2019
    Tax
    Office
    平成31

    View Slide

  12. How our system use Japanese era
    Bank
    Other
    Company
    2019
    Tax
    Office
    平成31
    平成31

    View Slide

  13. How our system use Japanese era
    Bank
    Other
    Company
    2019
    Tax
    Office
    平成31
    H.31
    平成31

    View Slide

  14. How our system use Japanese era
    Bank
    Other
    Company
    2019
    Tax
    Office
    平成31
    h31
    平成31
    H.31

    View Slide

  15. Patterns of usage of Japanese era
    - Pattern 1. Christian era (Our System) -> Japanese era (Other System)
    - Pattern 2. Japanese era (Other System) -> Christian era (Our System)

    View Slide

  16. Pattern 1. Christian era -> Japanese era
    - Examples:
    - 2019/04/30 -> 平成31年04月30日
    - 2019/05/01 -> 令和01年05月01日
    - We have only to care about the format of converted result (right-hand side)
    - That is because the original format (left-hand side) is stored in our DB as date
    type

    View Slide

  17. Pattern 2. Japanese era -> Christian era
    - Examples:
    - 平成31年04月30日 -> 2019/04/30
    - 令和01年05月01日 -> 2019/05/01

    View Slide

  18. Pattern 2. Japanese era -> Christian era
    - Examples:
    - 平成31年04月30日 -> 2019/04/30
    - 令和01年05月01日 -> 2019/05/01
    - 平成31年05月01日 -> ???

    View Slide

  19. Pattern 2. Japanese era -> Christian era
    - Examples:
    - 平成31年04月30日 -> 2019/04/30
    - 令和01年05月01日 -> 2019/05/01
    - 平成31年05月01日 -> 2019/05/01 #<- should be convertible

    View Slide

  20. Pattern 2. Japanese era -> Christian era
    - Examples:
    - 平成31年04月30日 -> 2019/04/30
    - 令和01年05月01日 -> 2019/05/01
    - 平成31年05月01日 -> 2019/05/01 #<- should be convertible
    - 令和01年04月30日 -> 2019/04/30 #<- should be convertible

    View Slide

  21. Pattern 2. Japanese era -> Christian era
    - Examples:
    - 平成31年04月30日 -> 2019/04/30
    - 令和01年05月01日 -> 2019/05/01
    - 平成31年05月01日 -> 2019/05/01 #<- should be convertible
    - 令和01年04月30日 -> 2019/04/30 #<- should be convertible
    - 令和元年05月01日 -> 2019/05/01 #<- should be convertible
    * “元年” means origin year. it’s used for year 1 of an era.

    View Slide

  22. Pattern 2. Requirements
    - 1. 令和{0,}1 #Kanji + half-width number
    - 2. 令和{0,}1 #Kanji + full-width number
    - 3. 令和元 #Kanji + 元年(origin year)
    - 4. R{0,}1 #Capital R without dot
    - 5. R.{0, 1} #Captial R with dot
    - 6. r.{0, 1} #samll r with dot
    - 7. 2019 #half-width number
    - 8. 2019 #full-width number
    - 9. Others (1~8 + some unnecessary characters or spaces may be included)
    *Needless to say, “平成”(the current Gengo) must be covered

    View Slide

  23. Ecosystem around Japanese era
    - Date#jisx0301
    - Ruby 2.6.3 was released yesterday
    - gem “wareki”
    - gem “era_ja”
    - They are nice! But none of them satisfy all our system’s unique requirements
    (before I mentioned).

    View Slide

  24. All of our steps
    1. Investigate the code which must be modified.
    2. Add test codes
    3. Refactor the code
    4. Make the code compatible with “Reiwa (令和)”

    View Slide

  25. 3. Refactor the code: the original code

    View Slide

  26. 3. Refactor the code: if statement part

    View Slide

  27. 3. Refactor the code: add Reiwa to RE?

    View Slide

  28. 3. Refactor the code: add Reiwa to RE?
    Only for Heisei (平成)

    View Slide

  29. 3. Refactor the code: add elsif statement for Reiwa?

    View Slide

  30. 3. Refactor the code: After 1

    View Slide

  31. 3. Refactor the code: After 2

    View Slide

  32. 3. Refactor the code: After final

    View Slide

  33. 4. Make the code compatible with “Reiwa(令和)”

    View Slide

  34. Conclusion
    - This talk was about the change of gengo and how our team dealt with it
    - The current Japanese era “Heisei (平成)” will end soon
    - Look forward to the new Japanese era “Reiwa (令和)”
    - We’re hiring!!

    View Slide