Comprehensive Chinese lunar calendar library with Solar calendar conversion and traditional Chinese calendar features.
79
Comprehensive Eight Character (BaZi) analysis system, Nine Star calculations, and advanced Chinese metaphysical analysis for fortune telling and personality assessment.
The core BaZi system analyzing four pillars (year, month, day, time) with comprehensive fortune-telling capabilities.
class EightChar:
@staticmethod
def fromLunar(lunar: 'Lunar') -> 'EightChar': ...
def getSect(self) -> int: ... # Calculation sect (1 or 2)
def setSect(self, sect: int): ...Basic four-pillar structure forming the foundation of BaZi analysis.
class EightChar:
# Year Pillar (年柱)
def getYear(self) -> str: ... # Year stem-branch combination
def getYearGan(self) -> str: ... # Year heavenly stem
def getYearZhi(self) -> str: ... # Year earthly branch
# Month Pillar (月柱)
def getMonth(self) -> str: ...
def getMonthGan(self) -> str: ...
def getMonthZhi(self) -> str: ...
# Day Pillar (日柱) - Most important pillar
def getDay(self) -> str: ...
def getDayGan(self) -> str: ... # Day Master (日主)
def getDayZhi(self) -> str: ...
# Time Pillar (时柱)
def getTime(self) -> str: ...
def getTimeGan(self) -> str: ...
def getTimeZhi(self) -> str: ...Hidden heavenly stems within earthly branches for detailed analysis.
class EightChar:
def getYearHideGan(self) -> list: ... # Hidden stems in year branch
def getMonthHideGan(self) -> list: ...
def getDayHideGan(self) -> list: ...
def getTimeHideGan(self) -> list: ...Five Elements strength and relationship analysis.
class EightChar:
def getYearWuXing(self) -> str: ... # Year pillar five element
def getMonthWuXing(self) -> str: ...
def getDayWuXing(self) -> str: ... # Day Master element
def getTimeWuXing(self) -> str: ...Traditional sound-based element classifications.
class EightChar:
def getYearNaYin(self) -> str: ...
def getMonthNaYin(self) -> str: ...
def getDayNaYin(self) -> str: ...
def getTimeNaYin(self) -> str: ...Relationship analysis based on interactions between heavenly stems.
class EightChar:
# Ten Gods for Heavenly Stems
def getYearShiShenGan(self) -> str: ... # Year stem Ten God
def getMonthShiShenGan(self) -> str: ...
def getDayShiShenGan(self) -> str: ... # Always "日主" (Day Master)
def getTimeShiShenGan(self) -> str: ...
# Ten Gods for Earthly Branches
def getYearShiShenZhi(self) -> list: ... # Year branch Ten Gods
def getMonthShiShenZhi(self) -> list: ...
def getDayShiShenZhi(self) -> list: ...
def getTimeShiShenZhi(self) -> list: ...Life cycle phases analysis for detailed fortune interpretation.
class EightChar:
def getYearDiShi(self) -> str: ... # Year growth phase
def getMonthDiShi(self) -> str: ...
def getDayDiShi(self) -> str: ...
def getTimeDiShi(self) -> str: ...Important palace calculations for comprehensive analysis.
class EightChar:
# Conception Palace (胎元)
def getTaiYuan(self) -> str: ...
def getTaiYuanNaYin(self) -> str: ...
# Breath Palace (胎息)
def getTaiXi(self) -> str: ...
def getTaiXiNaYin(self) -> str: ...
# Life Palace (命宫)
def getMingGong(self) -> str: ...
def getMingGongNaYin(self) -> str: ...
# Body Palace (身宫)
def getShenGong(self) -> str: ...
def getShenGongNaYin(self) -> str: ...Major life period fortune analysis and predictions.
class EightChar:
def getYun(self, gender: int, sect: int = 1) -> 'Yun': ...
# gender: 0=female, 1=male
# sect: calculation method (1 or 2)Detailed fortune cycle analysis classes for life period predictions.
class Yun:
def getGender(self) -> int: ... # 0=female, 1=male
def getStartYear(self) -> int: ... # Fortune cycle start year
def getStartAge(self) -> int: ... # Starting age
def isForward(self) -> bool: ... # Forward or reverse calculation
def getDaYun(self) -> list: ... # List of 10-year major cycles
def getXiaoYun(self) -> list: ... # List of yearly minor cycles
def getLiuNian(self, n: int) -> list: ... # List of n yearly cycles
class DaYun:
def getIndex(self) -> int: ... # Cycle index
def getStartYear(self) -> int: ... # Cycle start year
def getStartAge(self) -> int: ... # Starting age
def getEndYear(self) -> int: ... # Cycle end year
def getEndAge(self) -> int: ... # Ending age
def getGanZhi(self) -> str: ... # Cycle stem-branch
def getLiuYue(self) -> list: ... # Monthly cycles within this period
class XiaoYun:
def getYear(self) -> int: ... # Year
def getAge(self) -> int: ... # Age during this year
def getIndex(self) -> int: ... # Cycle index
def getGanZhi(self) -> str: ... # Year stem-branch
class LiuNian:
def getYear(self) -> int: ... # Year
def getAge(self) -> int: ... # Age
def getGanZhi(self) -> str: ... # Year stem-branch
class LiuYue:
def getIndex(self) -> int: ... # Month index
def getMonthInChinese(self) -> str: ... # Chinese month name
def getGanZhi(self) -> str: ... # Month stem-branch (Wu Hu Dun formula)
def getXun(self) -> str: ... # Sexagenary cycle
def getXunKong(self) -> str: ... # Cycle voidTraditional Nine Star calculations for metaphysical analysis.
class NineStar:
@staticmethod
def fromIndex(index: int) -> 'NineStar': ... # index: 0-8
def getIndex(self) -> int: ... # Star index (0-8)
def getNumber(self) -> str: ... # Star number (一-九)
def getColor(self) -> str: ... # Associated color
def getWuXing(self) -> str: ... # Five element
def getPosition(self) -> str: ... # Direction position
def getPositionDesc(self) -> str: ... # Position descriptionDifferent naming conventions for various metaphysical schools.
class NineStar:
def getNameInBeiDou(self) -> str: ... # Big Dipper names
def getNameInXuanKong(self) -> str: ... # Xuan Kong Feng Shui names
def getNameInQiMen(self) -> str: ... # Qi Men Dun Jia names
def getNameInTaiYi(self) -> str: ... # Tai Yi Shen Shu namesAdditional metaphysical attributes for detailed analysis.
class NineStar:
# Luck classifications
def getLuckInQiMen(self) -> str: ... # Qi Men luck classification
def getLuckInXuanKong(self) -> str: ... # Xuan Kong luck classification
# Other attributes
def getYinYangInQiMen(self) -> str: ... # Yin-Yang classification in Qi Men
def getTypeInTaiYi(self) -> str: ... # Type in Tai Yi system
def getBaMenInQiMen(self) -> str: ... # Eight Gates in Qi Men
def getSongInTaiYi(self) -> str: ... # Song formula in Tai Yi
def toString(self) -> str: ...
def toFullString(self) -> str: ...Access Nine Star calculations from various calendar contexts.
class Lunar:
def getNineStar(self) -> 'NineStar': ... # Day Nine Star
class LunarYear:
def getNineStar(self) -> 'NineStar': ... # Year Nine Star
class LunarMonth:
def getNineStar(self) -> 'NineStar': ... # Month Nine Star
class LunarTime:
def getNineStar(self) -> 'NineStar': ... # Time Nine Starfrom lunar_python import Lunar, EightChar
# Create lunar date
lunar = Lunar.fromYmd(1986, 4, 21)
# Get Eight Characters analysis
ba_zi = EightChar.fromLunar(lunar)
# Four Pillars
print("=== Four Pillars ===")
print(f"Year: {ba_zi.getYear()}") # 丙寅
print(f"Month: {ba_zi.getMonth()}") # 癸巳
print(f"Day: {ba_zi.getDay()}") # 癸酉 (Day Master)
print(f"Time: {ba_zi.getTime()}") # 子时
# Individual stems and branches
print("\n=== Stems and Branches ===")
print(f"Year Gan: {ba_zi.getYearGan()}, Zhi: {ba_zi.getYearZhi()}")
print(f"Day Gan (Day Master): {ba_zi.getDayGan()}")from lunar_python import Lunar, EightChar
lunar = Lunar.fromYmd(1986, 4, 21)
ba_zi = EightChar.fromLunar(lunar)
# Five Elements
print("=== Five Elements ===")
print(f"Year: {ba_zi.getYearWuXing()}")
print(f"Month: {ba_zi.getMonthWuXing()}")
print(f"Day (Day Master): {ba_zi.getDayWuXing()}")
print(f"Time: {ba_zi.getTimeWuXing()}")
# Ten Gods relationships
print("\n=== Ten Gods ===")
print(f"Year: {ba_zi.getYearShiShenGan()}")
print(f"Month: {ba_zi.getMonthShiShenGan()}")
print(f"Day: {ba_zi.getDayShiShenGan()}") # Always "日主"
print(f"Time: {ba_zi.getTimeShiShenGan()}")from lunar_python import Lunar, EightChar
lunar = Lunar.fromYmd(1986, 4, 21)
ba_zi = EightChar.fromLunar(lunar)
# Special palaces
print("=== Special Palaces ===")
print(f"Conception Palace: {ba_zi.getTaiYuan()}")
print(f"Life Palace: {ba_zi.getMingGong()}")
print(f"Body Palace: {ba_zi.getShenGong()}")
# Palace sound classifications
print(f"Life Palace NaYin: {ba_zi.getMingGongNaYin()}")from lunar_python import Lunar, EightChar
lunar = Lunar.fromYmd(1986, 4, 21)
ba_zi = EightChar.fromLunar(lunar)
# Get fortune cycles (gender: 1=male, 0=female)
yun = ba_zi.getYun(1) # Male
print(f"Fortune cycle starts at age: {yun.getStartAge()}")
print(f"Forward counting: {yun.isForward()}")
# Major 10-year cycles
da_yun_list = yun.getDaYun()
print("\n=== Major 10-Year Cycles ===")
for i, da_yun in enumerate(da_yun_list[:5]): # First 5 cycles
print(f"Age {da_yun.getStartAge()}-{da_yun.getEndAge()}: {da_yun.getGanZhi()}")
# Yearly cycles
xiao_yun_list = yun.getXiaoYun()
print(f"\n=== Some Yearly Cycles ===")
for i, xiao_yun in enumerate(xiao_yun_list[:10]): # First 10 years
print(f"Age {xiao_yun.getAge()}: {xiao_yun.getGanZhi()}")from lunar_python import Lunar, NineStar
lunar = Lunar.fromYmd(2023, 4, 11)
# Get Nine Star for this day
nine_star = lunar.getNineStar()
print("=== Nine Star Analysis ===")
print(f"Star Number: {nine_star.getNumber()}")
print(f"Color: {nine_star.getColor()}")
print(f"Five Element: {nine_star.getWuXing()}")
print(f"Position: {nine_star.getPosition()} ({nine_star.getPositionDesc()})")
# Different naming systems
print(f"Big Dipper name: {nine_star.getNameInBeiDou()}")
print(f"Xuan Kong name: {nine_star.getNameInXuanKong()}")
print(f"Qi Men name: {nine_star.getNameInQiMen()}")
# Luck classifications
print(f"Qi Men luck: {nine_star.getLuckInQiMen()}")
print(f"Xuan Kong luck: {nine_star.getLuckInXuanKong()}")from lunar_python import NineStar
# Create Nine Star from index (0-8)
star = NineStar.fromIndex(0) # First star (贪狼)
print(f"Star: {star.getNumber()} - {star.getNameInBeiDou()}")
print(f"Element: {star.getWuXing()}")
print(f"Position: {star.getPosition()}")from lunar_python import Lunar, EightChar
# Birth information
lunar = Lunar.fromYmd(1986, 4, 21)
ba_zi = EightChar.fromLunar(lunar)
print("=== Complete BaZi Analysis ===")
print(f"Birth: {lunar.toFullString()}")
print(f"Four Pillars: {ba_zi.getYear()} {ba_zi.getMonth()} {ba_zi.getDay()} {ba_zi.getTime()}")
# Day Master analysis (most important)
day_master = ba_zi.getDayGan()
day_element = ba_zi.getDayWuXing()
print(f"Day Master: {day_master} ({day_element})")
# Hidden stems analysis
print(f"Day Hidden Stems: {ba_zi.getDayHideGan()}")
# Growth phases
print(f"Day Growth Phase: {ba_zi.getDayDiShi()}")
# Sound classifications
nayin_list = [ba_zi.getYearNaYin(), ba_zi.getMonthNaYin(),
ba_zi.getDayNaYin(), ba_zi.getTimeNaYin()]
print(f"NaYin: {nayin_list}")Install with Tessl CLI
npx tessl i tessl/pypi-lunar-pythondocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10