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.1.tar.gz (2.5 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: khmerdate-0.1.1.tar.gz
  • Upload date:
  • Size: 2.5 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.1.tar.gz
Algorithm Hash digest
SHA256 ee271dac03363f27c230eb7368319af71f59c8c4cdd942dc413cda5f081f3e67
MD5 d0d0924bcde5d7ecf17e033b068abb52
BLAKE2b-256 9d4be9c06624ffe227b1132cc933d96572f49fc5f5b4390476aeec20b4843ac4

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