Skip to main content

jeraconv (Japanese Era Name Converter) is a converter that converts Japanese eras to West calendar.

Project description

jeraconv

jeraconv (Japanese Era Name Converter) is a converter that converts Japanese eras to West calendar.

Installation

$ pip install jeraconv

Usage

Japanese calendar to West calendar

from jeraconv import jeraconv

# Create J2W class instance
j2w = jeraconv.J2W()

# ex.1 : General usage
print(j2w.convert('文治6年'))
# result (int) 1190

# ex.2 : Full-width numbers are also available
print(j2w.convert('平成31年'))
# result (int) 2019

# ex.3 : It is also possible to write "1年" as "元年"
print(j2w.convert('令和元年'))
# result (int) 2019

# ex.4 : Returns a ValueError if the era name does not exist
print(j2w.convert('牌孫4年'))
# result ValueError

West calendar to Japanese calendar.

from jeraconv import jeraconv

# Create W2J class instance
w2j = jeraconv.W2J()

# ex.1 : General usage
year = 2019
month = 5
day = 31
print(w2j.convert(year, month, day))
# result (str) 令和1年5月31日

# ex.2 : When receiving a response in dictionary type
print(w2j.convert(year, month, day, return_type='dict'))
# result (dict) {'era': '令和', 'year': 1, 'month': 5, 'day': 31}

# ex.3 : When receiving a response in list type
print(w2j.convert(year, month, day, return_type='list'))
# result (list) ['令和', 1, 5, 31]

# ex.4 : When receiving a response in tuple type
print(w2j.convert(year, month, day, return_type='tuple'))
# result (tuple) ('令和', 1, 5, 31)

# ex.5 : If the date is omitted, convert the execution date
print(w2j.convert())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jeraconv-0.2.0-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

Details for the file jeraconv-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: jeraconv-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 13.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for jeraconv-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 07bea14875f7cd949d55ca0c2102d7fc9eceb64ead3bd79737e6dd1c0f2971ee
MD5 397c3c0a0ae81ec9239ccc50f12a0106
BLAKE2b-256 97f1a1392bb0a28cc1f3cab48cc85eb5c91dfd5a3e3e66bb823cd4c5d9de007b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page