Vietnamese lunar calendar conversion (Ho Ngoc Duc algorithm, per calrules) - Enterprise Ready
Project description
Am Lich Viet Nam
Python library for converting between Gregorian (solar) calendar and Vietnamese lunar calendar.
Goal: lightweight - simple – accurate – easy to reuse - Enterprise Ready
FEATURES
- No Dependencies: Ready for enterprise usage.
- Support Can Chi: Heavenly Stems and Earthly Branches for year, month, day, hour.
- Vietnamese Holidays: Common solar and lunar holidays included.
- Convert Solar → Lunar: (
dd/mm/yyyy → lunar day/month/year with leap month flag) - Convert Lunar → Solar: Accurate conversion using the Ho Ngoc Duc algorithm.
- Leap month support: Handled automatically.
- Timezone support: Default
UTC+7(Vietnam). - Processing Time Benchmark: High-performance conversions.
INSTALLATION
pip install lunar-vn
USAGE EXAMPLE
Basic Conversion
import datetime as dt
from lunar_vn import solar_to_lunar, lunar_to_solar, LunarDate
# Solar -> Lunar
l = solar_to_lunar((17, 2, 2026)) # Vietnamese Lunar New Year 2026
print(l) # LunarDate(day=1, month=1, year=2026, leap=False)
# Lunar -> Solar
d = lunar_to_solar(LunarDate(1, 1, 2026))
print(d) # 2026-02-17
Can Chi and Holidays
from lunar_vn import solar_to_lunar, can_chi, holidays
import datetime as dt
date = dt.date(2024, 2, 10)
lunar = solar_to_lunar(date)
# Get Year Can Chi
print(can_chi.get_year_can_chi(lunar.year)) # Giáp Thìn
# Get Day Can Chi (requires JDN)
from lunar_vn import jd_from_date
jdn = jd_from_date(date.day, date.month, date.year)
print(can_chi.get_day_can_chi(jdn)) # Giáp Thìn
# Check for Holiday
print(holidays.get_holiday(date)) # Tết Nguyên Đán
BENCHMARK
To run the benchmark script:
python scripts/benchmark.py
Expected: > 100,000 conversions per second.
COMPARISON WITH CHINESE LUNAR CALENDAR
See documentation.
ATTRIBUTION
The Vietnamese lunar calendar algorithm is described by Ho Ngoc Duc
on the website: https://xemamlich.uhm.vn
This library is a Python re-implementation of the published algorithm.
LICENSE
MIT License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lunar_vn-1.1.1.tar.gz.
File metadata
- Download URL: lunar_vn-1.1.1.tar.gz
- Upload date:
- Size: 9.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2c75ac7d8f2cf9d6c2bd8828060a3572be1369229e1051884ac3379fac83b1a
|
|
| MD5 |
0400f9aadf1f6f2f7d7b8f99828fffe0
|
|
| BLAKE2b-256 |
e14474dd78ca5c61ebb612c22fbaaeb6ac771141720f2a9293ce26ea55c53b35
|
Provenance
The following attestation bundles were made for lunar_vn-1.1.1.tar.gz:
Publisher:
publish.yml on junkeythong/amlichvietnam
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lunar_vn-1.1.1.tar.gz -
Subject digest:
b2c75ac7d8f2cf9d6c2bd8828060a3572be1369229e1051884ac3379fac83b1a - Sigstore transparency entry: 1154257724
- Sigstore integration time:
-
Permalink:
junkeythong/amlichvietnam@3c3680c4c26be8cafcef58dd9c3056bf6c2c44f2 -
Branch / Tag:
refs/tags/v1.1.1 - Owner: https://github.com/junkeythong
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3c3680c4c26be8cafcef58dd9c3056bf6c2c44f2 -
Trigger Event:
release
-
Statement type:
File details
Details for the file lunar_vn-1.1.1-py3-none-any.whl.
File metadata
- Download URL: lunar_vn-1.1.1-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a76dc3a68ceeb61025c3e571185cfe917ad73fa86c21785b519d802ff10591b
|
|
| MD5 |
dd3cd17095e6afb3d976f50c5c0f6a18
|
|
| BLAKE2b-256 |
20e4db7bd5bd1e0e15c3c65c78f98c7574bc88843dd24f70c7b17a78907c8efa
|
Provenance
The following attestation bundles were made for lunar_vn-1.1.1-py3-none-any.whl:
Publisher:
publish.yml on junkeythong/amlichvietnam
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lunar_vn-1.1.1-py3-none-any.whl -
Subject digest:
9a76dc3a68ceeb61025c3e571185cfe917ad73fa86c21785b519d802ff10591b - Sigstore transparency entry: 1154257725
- Sigstore integration time:
-
Permalink:
junkeythong/amlichvietnam@3c3680c4c26be8cafcef58dd9c3056bf6c2c44f2 -
Branch / Tag:
refs/tags/v1.1.1 - Owner: https://github.com/junkeythong
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3c3680c4c26be8cafcef58dd9c3056bf6c2c44f2 -
Trigger Event:
release
-
Statement type: