Skip to main content

handle japanese time format

Project description

jptime

jptime handle japanese time format.

Installation

pip install jptime

Usage

from datetime import datetime
import jptime

# from string
jpt = jptime.from_str("平成元年三月三日")
assert jpt.to_tuple() == (4, 1, 3, 3)
assert jpt.to_datetime() == datetime(1989, 3, 3)

# from datetime
jpt = jptime.from_datetime(datetime(2019, 5, 1))
assert jpt.to_tuple() == (5, 1, 5, 1) # 令和1年5月1日

Supported formats

  • japanese era
    • era_symbol/yy/mm/dd (allow kanji number) (e.g. 昭和5年3月3日)
    • era_code + yymmdd (e.g. 3031123)
  • christian era (delegate to dateutil.parser) (e.g. 19920323, 2018-12-12)

Download files

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

Files for jptime, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size jptime-1.0.0-py3-none-any.whl (4.4 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size jptime-1.0.0.tar.gz (4.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page