Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getJalaaliDatetime(gregorianMoment, jalaliMonths) {
var jalaliDate = jalali.toJalaali(
gregorianMoment.year(),
gregorianMoment.month() + 1,
gregorianMoment.date()
);
var output =
// eslint-disable-next-line prefer-template
jalaliDate.jd + ' ' + jalaliMonths[jalaliDate.jm - 1] + ' ' + jalaliDate.jy;
return output;
}
formatDate: gregorianMoment => {
if (isSupportedMoment(gregorianMoment)) {
const jalaaliDate = jalaaliJs.toJalaali(
gregorianMoment.year(),
gregorianMoment.month() + 1,
gregorianMoment.date(),
);
const localeJalaaliMonths = jalaaliMonths[gregorianMoment.locale()];
const jalaaliMonth = localeJalaaliMonths[jalaaliDate.jm - 1];
const output = `${jalaaliDate.jd} ${jalaaliMonth} ${jalaaliDate.jy}`;
return output;
}
return null;
},
};
function toJalaali(gy, gm, gd) {
var j = jalaali.toJalaali(gy, gm + 1, gd)
j.jm -= 1
return j
}
const getToday = () => {
const todayDate = new Date();
const year = todayDate.getFullYear();
const month = todayDate.getMonth() + 1;
const day = todayDate.getDate();
if (isGregorian) return { year, month, day };
const { jy, jm, jd } = jalaali.toJalaali(year, month, day);
const currentDate = { year: jy, month: jm, day: jd };
return currentDate;
};