chinese-lunar-date API - v1.0.5
    Preparing search index...

    Function parseGanZhi

    Heavenly Stems (天干) and Earthly Branches (地支) calculations. Used for year/month/day pillars in traditional Chinese timekeeping.

    • Parse a GanZhi string back to pair indices

      Parameters

      • str: string

        A 2-character GanZhi string (e.g., "甲子")

      Returns GanZhiPair | null

      The corresponding GanZhi pair, or null if invalid

      parseGanZhi('甲子')  // { gan: 0, zhi: 0 }
      parseGanZhi('丁酉') // { gan: 3, zhi: 9 }
      parseGanZhi('XX') // null