Skip to main content

๐Ÿ‡ฐ๐Ÿ‡ญ 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, today

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)
# => แžแŸ’แž„แŸƒแžขแž„แŸ’แž‚แžถแžš แŸฆแž€แžพแž แžแŸ‚แžขแžถแžŸแžถแž แž†แŸ’แž“แžถแŸ†แž˜แŸ’แžŸแžถแž‰แŸ‹ แžŸแž”แŸ’แžแžŸแŸแž€ แž–.แžŸ. แŸขแŸฅแŸฆแŸฉ

print(today())
# => แžแŸ’แž„แŸƒแžŸแŸ…แžšแŸ แŸฉแžšแŸ„แž… แžแŸ‚แžขแžถแžŸแžถแž แž†แŸ’แž“แžถแŸ†แž˜แŸ’แžŸแžถแž‰แŸ‹ แžŸแž”แŸ’แžแžŸแŸแž€ แž–.แžŸ. แŸขแŸฅแŸฆแŸฉ

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

Uploaded Source

File details

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

File metadata

  • Download URL: khmerdate-0.1.3.tar.gz
  • Upload date:
  • Size: 7.1 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.3.tar.gz
Algorithm Hash digest
SHA256 0ce4cbed64ac3e8003aa61dbc0371b0e361d30f139dbb30b6445b4553fe28cfa
MD5 f3d505cbb3e7bd7e39a2dc9a3c3e6b29
BLAKE2b-256 7c143a8b12aa721b214e20bdb7142f736116f442412e859705bdf932de64cb58

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.3 This release

1 file

0.1.2

1 file

0.1.1

1 file

0.1.0

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page