twdate
A simple Python package to convert between the Gregorian calendar and the Taiwanese (Minguo) calendar.
Installation
pip install twdate
Usage
Create a Minguo date
from twcal import TWDate
d = TWDate(115, 3, 20) # 民國115年3月20日
Convert between Gregorian and Minguo
import datetime
from twcal import to_minguo, to_gregorian
# Gregorian -> Minguo
tw = to_minguo(datetime.date(2026, 3, 20))
# TWDate(year=115, month=3, day=20)
# Minguo -> Gregorian
gd = to_gregorian(tw)
# datetime.date(2026, 3, 20)
Get today's date in Minguo format
from twcal import today
d = today()
print(d) # 民國115年3月20日
Format as string
d = TWDate(115, 3, 20)
d.to_string() # '民國115年3月20日'
d.to_short_string() # '1150320'
str(d) # '民國115年3月20日'
Parse from short string
d = TWDate.from_short_string("1150320")
# TWDate(year=115, month=3, day=20)
Pre-Minguo dates
import datetime
from twcal import to_minguo
d = to_minguo(datetime.date(1911, 1, 1))
# TWDate(year=-1, month=1, day=1)
print(d) # 民國前1年1月1日
CLI
# Show today's date in Minguo format
twdate now
# Convert Gregorian to Minguo
twdate convert 2026-03-20
# Convert Minguo to Gregorian
twdate convert -g 115-03-20
Comparison
from twcal import TWDate
TWDate(115, 1, 1) > TWDate(114, 12, 31) # True
TWDate(114, 1, 1) < TWDate(115, 1, 1) # True
Validation
from twcal import TWDate
TWDate(0, 1, 1) # ValueError: 民國0年不存在
TWDate(115, 2, 30) # ValueError: day is out of range for month
License
This project is licensed under the MIT License. You are free to use, modify, and distribute this software for any purpose, including commercial use.
Release files for twdate 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| twdate-1.1.0.tar.gz | 3.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| twdate-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.3 kB
Release files / twdate-1.1.0.tar.gz
| Download URL | twdate-1.1.0.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
991ef61df276f9c94c2a98d0aa8ec8c033598cec2e5e5f448667fa6ed1cfd9a5
|
|
BLAKE2b-256 checksum How to use checksums |
84553c4c8794b790dedccf280a2d5539f1040f9d733ee14a1316db4f225cbe2f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 20, 2026.
Transparency logRelease files / twdate-1.1.0-py3-none-any.whl
| Download URL | twdate-1.1.0-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5f3753b09a6d840c9832aa256d587eb68ef0c2102f57f963f2911e4f1eedd14d
|
|
BLAKE2b-256 checksum How to use checksums |
db68b23b0074bf5aa135d707c0bd0ba328320ad6cc4d14ab69631bea302f969a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 20, 2026.
Transparency log