Skip to main content
===========================
A Brief Introduction
===========================

This a tool for conversion between Chinese regnal year and Comman Era,
and a module can be directly used in python.

*This is just an alpha version, which only supports years from Ming Dynasty till doday, and there may be some mistakes. More data will be added in the future.*

Examples:

============ ============
清乾隆元年 1736年
============ ============
明正德十二年 1517年
============ ============
民國20年 1931年
============ ============
一九八〇年 1980年
============ ============
1621年 明天啓元年
============ ============
1861年 清咸豐十一年
============ ============
1948年 民國37年
============ ============

Installation
===============

::

pip install cnyear

Usage Samples
=================

.. code:: python

from cnyear import Cnyear

# get the Common Era for a Chinese regnal year
year_obj1 = Cnyear('清康熙十二年')
year_obj1.cny2y() # return a tuple (1673, None, True) which means (first year, last year, validity)
year_obj1.y2cny(dig=True) # 清康熙12年

# get a span of time
year_obj2 = Cnyear('明正統間')
year_obj2.cny2y() # (1436, 1449, True)

# correct the wrong regnal year
year_obj3 = Cnyear('清咸豐十二年')
year_obj3.cny2y() # (1862, None, False)
year_obj3.y2cny() # 清同治元年

# get the Chinese regnal year for a Common Era
Cnyear('明崇禎十八年').y2cny(ldefaultdy=['清','南明']) # 清順治二年
Cnyear('明崇禎十八年').y2cny(ldefaultdy=['南明','清']) # 南明弘光元年


Other Features
===================

#. Convert an invalid Chinese regnal year into a valid Chinese regnal year.
#. Convert Chinese digit numbers into Arabic digit numbers in a year and vice versa.
#. Get each component in an expression of year.

Future Features
===================

#. To support sexagenary cycle 干支.
#. To support operand like minus and plus between years.

Acknowledgement
===================

All the year data come from *Zhongguo Lishi Jinianbiao* (中國歷史紀年表).

Metadata

Release files for cnyear 0.0.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cnyear 0.0.12
File Size Uploaded Provenance Actions
cnyear-0.0.12.tar.gz 19.1 kB Without provenance Details for cnyear-0.0.12.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cnyear 0.0.12
File Interpreter ABI Platform Actions
cnyear-0.0.12-py3-none-any.whl Python 3 none any Details for cnyear-0.0.12-py3-none-any.whl

Total release size: 56.5 kB

Release files / cnyear-0.0.12.tar.gz

Download URL cnyear-0.0.12.tar.gz
Size 19.1 kB
Tags Source
SHA-256 checksum
How to use checksums
9361adeac0924c91fa30e076dc749dc40b28bfb05fdc98549683787cd1573eb4
BLAKE2b-256 checksum
How to use checksums
a110289b6f82b54413908f55d628ec4e5b5a930a2ed38bb81a8d84e5b36a0c39
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Python-urllib/3.6

Release files / cnyear-0.0.12-py3-none-any.whl

Download URL cnyear-0.0.12-py3-none-any.whl
Size 37.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ca0b17aca4a04f02f68514b36e036f22c539340f2388645eef47667fdcf7924c
BLAKE2b-256 checksum
How to use checksums
3980beee1d007f976b39ea4de54153f035910e375a4aac41b097820afad1985c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Python-urllib/3.6

Security for cnyear 0.0.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page