UNPKG

@xuda.io/xuda-ui-plugin-jewish-date

Version:

The Jewish Date Xuda Plugin integrates Hebrew calendar functionality into Xuda.io, enabling seamless conversion between Gregorian and Jewish dates. Display dates in English or Hebrew, with optional dual-calendar support, localization, and custom date inpu

46 lines (39 loc) 1.28 kB
import { toJewishDate, formatJewishDate, toHebrewJewishDate, formatJewishDateInHebrew, toGregorianDate, JewishMonth, } from "jewish-date"; export const fn = function (plugin_name, el, properties) { const includeGregorian = properties.jewish_date_include_gregorian?.value || false; const displayInHebrew = properties.jewish_date_display_in_hebrew?.value || false; const customDate = properties.jewish_date_custom_date?.value || null; // Use custom date or fallback to today const date = customDate ? new Date(customDate) : new Date(); // Convert to Jewish date const jewishDate = toJewishDate(date); // Format Jewish date based on selected language const formattedJewishDate = displayInHebrew ? formatJewishDateInHebrew(jewishDate) : formatJewishDate(jewishDate); // // Format Gregorian date if included // const formattedGregorianDate = includeGregorian // ? date.toLocaleDateString("en-US", { // year: "numeric", // month: "long", // day: "numeric", // }) // : null; el.innerHTML = (includeGregorian ? date.toLocaleDateString("en-US", { year: "numeric", month: "long", day: "numeric", }) + " " : "") + formattedJewishDate; };