Project

nengo

0.0
No commit activity in last 3 years
No release in over 3 years
A simple ruby gem to convert years to various Japanese date systems
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

>= 0
 Project Readme

nengo

Code Climate

Ruby Gem to convert between Japanese year formats and check age and zodiac information for given years.

Usage

Install the gem

gem install nengo

or put the following in your Gemfile

gem 'nengo'

Note: requires the 'json' gem

Then simply require 'nengo' in the file(s) where you want to use it

require 'nengo'

Examples

Get current 和暦年号 (Wareki nengo) year and epoch name:

current_year = Nengo.new # default is this year
current_year.data_nengo[:year_rel]
# => 27
current_year.data_nengo[:name]
# => 平成

Get current age of person born in 昭和 (Shouwa) 50

year = Nengo.new
year.set_by_nengo(jidai: "昭和", year_rel: 50)
year.nenrei
# => 40

So someone born in the year 昭和 (Shouwa) 50 is currently 40-41 years old.

Get the 和暦年号 (Wareki nengo) year and epoch name of the year in which a person who is now 25 years old was born

year = Nengo.new
year.set_by_nenrei(20)
year.data_nengo["name"]
# => 平成
year.data_nengo["year_rel"]
# => 7

So someone who's currently 20 years old was born in the 7th (or possibly 6th, but we can't know without specifying the exact date) of the Heisei epoch.

Get the 干支 (Japanese Zodiac) and Koki (皇紀) information for someone born in 1960

year = Nengo.new(1960)
year.data_eto
# => { :year_rel=>37,
#      :animal=> {"id"=>8, "name"=>"辛", "reading_kanji"=>"金の弟", "reading_kana"=>"かのと"},
#      :element=> {"id"=>1, "name"=>"子", "reading_on"=>"し", "reading_kun"=>"ね"}
#    }
year.year_koki
# => 2620

As you can see, a large number of possible conversions are possible.

Data included

  • 西暦 (Western) year
  • 年号 (Japanese system based on emperors' lifespans) data
  • 年齢 (Current age of people born in the given year) year
  • 干支 (Chinese zodiac) data
  • 皇紀 (Imperial Japanese calendar) year

Todo

  • Write tests
  • Refactor so it's not necessary to store the full list of jidais in each Nengo object
  • Fix inconsistencies between string and symbol keys for hashes