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

    Function parseGregorian

    Date formatting with pattern tokens. See PATTERNS for presets and the format function docs for the full token reference table.

    • Parse a Gregorian date string into { year, month, day }

      Supports formats:

      • ISO: "2025-10-11"
      • Slash: "2025/10/11"
      • Chinese: "2025年10月11日"

      Parameters

      • str: string

        Date string

      Returns GregorianDate | null

      GregorianDate or null if unparseable

      parseGregorian('2025-10-11')  // { year: 2025, month: 10, day: 11 }
      parseGregorian('2025/10/11') // { year: 2025, month: 10, day: 11 }
      parseGregorian('2025年10月11日') // { year: 2025, month: 10, day: 11 }