wareki

package module
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 6, 2023 License: MIT Imports: 2 Imported by: 0

README

English | 日本語

wareki

Build Status CI MIT License GoDoc Go Report Card Version

wareki converts between Japanese calendar and western calendar.

Description

wareki converts between Japanese calendar and western calendar.

When converting from the Western calendar to the Japanese calendar, the era of the Japanese calendar is automatically determined according to the Western calendar. The year of Western calendar can be omitted and the default value is the system date.

By default, the Japanese era is output with one uppercase letter (e.g. R) but can also be output with kanji (e.g. 令和) You can also convert from Japanese calendar to Western calendar by specifying an option.

wareki support Reiwa, Heisei, Taisho, Meiji.

Usage

$ date "+%Y/%m/%d"
2019/05/01

$ wareki
R1

$ wareki --kanji
令和1

$ wareki 2018
H30

$ wareki 2019/05/01
R1

$ wareki 2019/04/30
H31

$ wareki --reiwa 1
2019

$ wareki --heisei 1
1989

$ wareki --heisei 1
1989

$ wareki --showa 1
1926

$ wareki --help
# ...

Or, you can use Docker.

$ date "+%Y/%m/%d"
2019/05/01

$ docker container run --rm ebc2in2crc/wareki
R1

$ docker container run --rm ebc2in2crc/wareki --kanji
令和1

Installation

Developer

Go 1.16 or later.

$ go install github.com/ebc-2in2crc/wareki/cmd/wareki@latest

Go 1.15.

$ go get -u github.com/ebc-2in2crc/wareki/...
User

Download from the following url.

Or, you can use Homebrew (Only macOS).

$ brew tap ebc-2in2crc/wareki
$ brew install wareki

Or, you can use Docker.

$ docker pull ebc2in2crc/wareki
$ docker container run ebc2in2crc/wareki
R4

Contribution

  1. Fork this repository
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Rebase your local changes against the master branch
  5. Run test suite with the go test ./... command and confirm that it passes
  6. Run gofmt -s
  7. Create new Pull Request

License

MIT

Author

ebc-2in2crc

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Gengo added in v1.0.0

type Gengo struct {
	// contains filtered or unexported fields
}

Gengo represents Japanese era.

func Date added in v1.0.0

func Date(t time.Time) (*Gengo, error)

Date returns a Gengo that always uses the given time.Time.

func HEISEI added in v1.0.0

func HEISEI() *Gengo

HEISEI returns a Gengo that represents HEISEI era.

func MEIJI added in v1.0.0

func MEIJI() *Gengo

MEIJI returns a Gengo that represents MEIJI era.

func Now added in v1.0.0

func Now() (*Gengo, error)

Now returns a current Gengo.

func REIWA added in v1.0.0

func REIWA() *Gengo

REIWA returns a Gengo that represents REIWA era.

func SHOWA added in v1.0.0

func SHOWA() *Gengo

SHOWA returns a Gengo that represents SHOWA era.

func TAISHO added in v1.0.0

func TAISHO() *Gengo

TAISHO returns a Gengo that represents TAISHO era.

func Values added in v1.0.0

func Values() []*Gengo

Values returns an array That includes all Gengo.

func (*Gengo) Between added in v1.0.0

func (g *Gengo) Between(t time.Time) bool

Between reports whether t is between Gengo.

func (*Gengo) Convert added in v1.0.0

func (g *Gengo) Convert(t time.Time) int

Convert converts western calendar into Japanese calendar.

func (*Gengo) KanjiName added in v1.0.0

func (g *Gengo) KanjiName() string

KanjiName returns a kanji representation of the Gengo.

func (*Gengo) Name added in v1.0.0

func (g *Gengo) Name() string

Name returns a romanized representation of the Gengo.

func (*Gengo) ShortName added in v1.0.0

func (g *Gengo) ShortName() string

ShortName returns a short romanized representation of the Gengo.

func (*Gengo) ToAC added in v1.0.0

func (g *Gengo) ToAC(year int) int

ToAC converts Japanese calendar into western calendar.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL