Overview
This node converts dates between the Vietnamese solar calendar (Gregorian) and the Vietnamese lunar calendar. It supports two main operations:
- Solar to Lunar: Converts a given Gregorian date (either the current date or a specified date) into its corresponding lunar calendar date.
- Lunar to Solar: Converts a specified lunar calendar date (including leap month information) into the corresponding Gregorian date.
This node is useful for applications that need to work with traditional Vietnamese lunar dates alongside standard Gregorian dates, such as cultural event planning, astrology, or historical data processing.
Practical Examples
- Automatically converting today's Gregorian date to the Vietnamese lunar date for daily horoscope or festival notifications.
- Converting a specific lunar birthday to the Gregorian calendar to set reminders or schedule events.
- Handling leap months in the lunar calendar when converting dates for accurate cultural observances.
Properties
| Name | Meaning |
|---|---|
| Thao tác | Operation to perform: "Dương lịch sang Âm lịch" (Solar to Lunar) or "Âm lịch sang Dương lịch" (Lunar to Solar) |
| Nguồn dữ liệu | Data source for conversion when operation is Solar to Lunar: "Ngày hiện tại" (Current date), "Ngày cụ thể" (Specific date) |
| Ngày | Day of the month (number). Used when specifying a specific date for conversion (Solar to Lunar or Lunar to Solar). |
| Tháng | Month of the year (number). Used when specifying a specific date for conversion (Solar to Lunar or Lunar to Solar). |
| Năm | Year (number). Used when specifying a specific date for conversion (Solar to Lunar or Lunar to Solar). |
| Ngày âm lịch | Lunar day (number). Used when operation is Lunar to Solar. |
| Tháng âm lịch | Lunar month (number). Used when operation is Lunar to Solar. |
| Năm âm lịch | Lunar year (number). Used when operation is Lunar to Solar. |
| Tháng nhuận | Boolean indicating if the lunar month is a leap month. Used when operation is Lunar to Solar. |
Output
The output JSON contains detailed information about both the solar and lunar dates involved in the conversion:
For Solar to Lunar:
solar: Object with propertiesday,month,year, andleap_yearindicating the Gregorian date.lunar: Object with propertiesday,month,year,leap_year,leap_month, and string names for the year, month, and day according to Vietnamese lunar calendar traditions.julian: Julian day number of the lunar date.
For Lunar to Solar:
lunar: Object with lunar date details similar to above.solar: Object with Gregorian date details including a JavaScript Date object (date).julian: Julian day number of the lunar date.
If an error occurs during processing, the output JSON will contain an error field with the error message.
The node does not output binary data.
Dependencies
- Uses the external library
@nghiavuive/lunar_date_vifor date conversions between solar and lunar calendars. - Requires no special API keys or external services.
- No additional environment variables or n8n credentials are needed.
Troubleshooting
Common issues:
- Providing invalid or out-of-range dates (e.g., day > 31, month > 12) may cause errors.
- Incorrect leap month flag when converting from lunar to solar can lead to wrong results.
- Using "Ngày hiện tại" (current date) option requires the system clock to be correct.
Error messages:
- Errors thrown by the underlying date conversion library will be caught and returned in the output under the
errorkey. - If the node is configured to stop on failure, these errors will halt execution with a descriptive message.
- Errors thrown by the underlying date conversion library will be caught and returned in the output under the
Resolution:
- Verify input dates are valid and consistent.
- Ensure leap month boolean is correctly set for lunar dates.
- Use the "Ngày cụ thể" option to specify exact dates if automatic current date conversion fails.
Links and References
- Vietnamese Lunar Calendar npm package (@nghiavuive/lunar_date_vi) (for more details on the underlying date conversion logic)
- General information on Vietnamese lunar calendar concepts and leap months can be found on Wikipedia or cultural websites.