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

Uploaded Source

File details

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

File metadata

  • Download URL: khmerdate-0.1.2.tar.gz
  • Upload date:
  • Size: 7.0 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.2.tar.gz
Algorithm Hash digest
SHA256 320015cc3024dc93755f5a017f743d8a7271529b60712223752b6095b6159fed
MD5 3a0723cb035dd77a763c1dc268291608
BLAKE2b-256 030cfb4dcf80b076e8e1dea681e76602a63b34ae193c6b53506c4eb86dd1ec64

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