korean-lunar-calendar

Korean Lunar Calendar


Keywords
calendar, korean, lunar
License
MIT
Install
pip install korean-lunar-calendar==0.2.1

Documentation

korean_lunar_calendar

Library to convert Korean lunar-calendar to Gregorian calendar.

Overview

Korean calendar and Chinese calendar is same lunar calendar but have different date. This follow the KARI(Korea Astronomy and Space Science Institute) ν•œκ΅­ μ–‘μŒλ ₯ λ³€ν™˜ (ν•œκ΅­μ²œλ¬Έμ—°κ΅¬μ› κΈ°μ€€) - λ„€νŠΈμ›Œν¬ μ—°κ²° λΆˆν•„μš”

음λ ₯ 지원 λ²”μœ„ (1000λ…„ 01μ›” 01일 ~ 2050λ…„ 11μ›” 18일)
Korean Lunar Calendar (1000-01-01 ~ 2050-11-18)

μ–‘λ ₯ 지원 λ²”μœ„ (1000λ…„ 02μ›” 13일 ~ 2050λ…„ 12μ›” 31일)
Gregorian Calendar (1000-02-13 ~ 2050-12-31)

Example Site

Docs

Install

pip install korean_lunar_calendar

Import

from korean_lunar_calendar import KoreanLunarCalendar

Example

Korean Solar Date -> Korean Lunar Date (μ–‘λ ₯ -> 음λ ₯)

calendar = KoreanLunarCalendar()

# params : year(λ…„), month(μ›”), day(일)
calendar.setSolarDate(2017, 6, 24)

# Lunar Date (ISO Format)
print(calendar.LunarIsoFormat())

# Korean GapJa String
print(calendar.getGapJaString())

# Chinese GapJa String
print(calendar.getChineseGapJaString())
[Result]
2017-05-01 Intercalation
μ •μœ λ…„ λ³‘μ˜€μ›” μž„μ˜€μΌ (μœ€μ›”)
丁酉年 δΈ™εˆζœˆ 壬午ζ—₯ (ι–ζœˆ)

Korean Lunar Date -> Korean Solar Date (음λ ₯ -> μ–‘λ ₯)

calendar = KoreanLunarCalendar()

# params : year(λ…„), month(μ›”), day(일), intercalation(μœ€λ‹¬μ—¬λΆ€)
calendar.setLunarDate(1956, 1, 21, False)

# Solar Date (ISO Format)
print(calendar.SolarIsoFormat())

# Korean GapJa String
print(calendar.getGapJaString())

# Chinese GapJa String
print(calendar.getChineseGapJaString())
[Result]
1956-03-03
병신년 경인월 기사일
δΈ™η”³εΉ΄ εΊšε―…ζœˆ ε·±ε·³ζ—₯

Validation

Check for invalid date input

calendar = KoreanLunarCalendar()

# invald date
calendar.setLunarDate(99, 1, 1, False) # => return False
calendar.setSolarDate(2051, 1, 1) # => return False

# OK
calendar.setLunarDate(1000, 1, 1, False) # => return True
calendar.setSolarDate(2050, 12, 31) # => return True

Other languages