Skip to main content

Khmer Lunar Date Converter

Project description

🇰🇭 Khmer Lunar Date Converter

A Python script to convert the Gregorian date into the Khmer lunar calendar — complete with lunar day (កើត/រោច), lunar month (including leap detection), zodiac animal year, heavenly stem (ស័ក), weekday in Khmer, and Buddhist year (ព.ស.).

This project is created to support Cambodian culture and make Khmer calendar logic accessible through code.


🙏 Sponsored by Hun Vannak

This open-source project is proudly sponsored by Hun Vannak, who supports the preservation of Khmer heritage through technology and innovation.


✨ Features

  • Convert today's Gregorian date to Khmer lunar date
  • Accurate new moon calculation for lunar day
  • Detect leap months using solar longitude
  • Show Khmer zodiac animal and heavenly stem
  • Convert all numbers to Khmer numerals
  • Output Buddhist year (ព.ស.)
  • Localized Khmer weekday name

🚀 Usage

# from pypi
pip install khmerdate

# or directly from source
pip install git+https://github.com/danhhong/khmer_lunar_date.git

import datetime
from khmerdate import gregorian_to_khmer_lunar, khmer_day_of_week

day, month, year = 1, 7, 2025

result = gregorian_to_khmer_lunar(day, month, year)
print(result)

# =>
{
    "lunar_day": "៦កើត",
    "lunar_month": "អាសាឍ",
    "lunar_year": "២៥៦៩",
    "zodiac_year": "ម្សាញ់",
    "stem": "សប្តស័ក",
}

# formatting as string
day_name = datetime.datetime(year, month, day).strftime("%A")
day_name = khmer_day_of_week[day_name]

result_fmt = f"ថ្ងៃ{day_name} {result['lunar_day']} ខែ{result['lunar_month']} ឆ្នាំ{result['zodiac_year']} {result['stem']} ព.ស. {result['lunar_year']}"

print(result_fmt)
# => ថ្ងៃអង្គារ ៦កើត ខែអាសាឍ ឆ្នាំម្សាញ់ សប្តស័ក ព.ស. ២៥៦៩

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

khmerdate-0.1.0.tar.gz (2.4 kB view details)

Uploaded Source

File details

Details for the file khmerdate-0.1.0.tar.gz.

File metadata

  • Download URL: khmerdate-0.1.0.tar.gz
  • Upload date:
  • Size: 2.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.19

File hashes

Hashes for khmerdate-0.1.0.tar.gz
Algorithm Hash digest
SHA256 faf9fce89fcc71bad7484a5737d8c487160abc1022071608898d1cdde5b160f0
MD5 c5e304a4ef7a4692d0d2d6b10bc35381
BLAKE2b-256 31fb7f24fb8f033a2ba5d44d8de2a49b74febf2120945cb3350a363379369416

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