Converts a given solar (Gregorian) date to a lunar (Chinese) date. The function calculates the corresponding lunar year, month, day, and whether the month is a leap month. If the solar date is invalid or out of range, it returns -1.
The solar date to convert. It should be a valid JavaScript Date object.
Date
A LunarDate object representing the corresponding lunar date, or -1 if the solar date is invalid.
// => { year: 2024, month: 2, day: 10, isLeapMonth: false }toLunar(new Date('2024-01-01')) Copy
// => { year: 2024, month: 2, day: 10, isLeapMonth: false }toLunar(new Date('2024-01-01'))
// => -1toLunar(new Date('1900-01-30')) Copy
// => -1toLunar(new Date('1900-01-30'))
// => -1toLunar(new Date('2101-01-01')) Copy
// => -1toLunar(new Date('2101-01-01'))
Converts a given solar (Gregorian) date to a lunar (Chinese) date. The function calculates the corresponding lunar year, month, day, and whether the month is a leap month. If the solar date is invalid or out of range, it returns -1.