Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if(tableRowData && index < 7) {
//remove html tag and trim
var item = striptags(tableRowData).trim();
//convert arabic character to persian number
if(item) {
item = persian(item)
.arabicChar()
.toString();
}
//format and convert city creation date to iso format
if (index === 2) {
var cityCreationDate = item.split('/');
if(cityCreationDate.length > 1) {
var cityCreationDateGregorian = jalaali.toGregorian(parseInt(cityCreationDate[0]), parseInt(cityCreationDate[1]), parseInt(cityCreationDate[2]));
cityCreationDateGregorian = new Date(cityCreationDateGregorian.gy, cityCreationDateGregorian.gm, cityCreationDateGregorian.gd);
city['city_creation_date_iso'] = cityCreationDateGregorian.toISOString();
} else {
var cityCreationDateGregorian = jalaali.toGregorian(parseInt(cityCreationDate[0]), 1, 1);
cityCreationDateGregorian = new Date(cityCreationDateGregorian.gy, cityCreationDateGregorian.gm, cityCreationDateGregorian.gd);
city['city_creation_date_iso'] = cityCreationDateGregorian.toISOString();
}
}
//create city object based on schema
city[schema[index]] = item;
}
});
if(item) {
item = persian(item)
.arabicChar()
.toString();
}
//format and convert city creation date to iso format
if (index === 2) {
var cityCreationDate = item.split('/');
if(cityCreationDate.length > 1) {
var cityCreationDateGregorian = jalaali.toGregorian(parseInt(cityCreationDate[0]), parseInt(cityCreationDate[1]), parseInt(cityCreationDate[2]));
cityCreationDateGregorian = new Date(cityCreationDateGregorian.gy, cityCreationDateGregorian.gm, cityCreationDateGregorian.gd);
city['city_creation_date_iso'] = cityCreationDateGregorian.toISOString();
} else {
var cityCreationDateGregorian = jalaali.toGregorian(parseInt(cityCreationDate[0]), 1, 1);
cityCreationDateGregorian = new Date(cityCreationDateGregorian.gy, cityCreationDateGregorian.gm, cityCreationDateGregorian.gd);
city['city_creation_date_iso'] = cityCreationDateGregorian.toISOString();
}
}
//create city object based on schema
city[schema[index]] = item;
}
});
function toGregorian(jy, jm, jd) {
var g = jalaali.toGregorian(jy, jm + 1, jd)
g.gm -= 1
return g
}
const getMonthFirstWeekday = date => {
const gregorianFirstDay = isGregorian
? { gy: date.year, gm: date.month, gd: 1 }
: jalaali.toGregorian(date.year, date.month, 1);
const gregorianDate = new Date(
gregorianFirstDay.gy,
gregorianFirstDay.gm - 1,
gregorianFirstDay.gd,
);
const weekday = gregorianDate.getDay();
if (isGregorian) return weekday;
return weekday < 6 ? weekday + 1 : 0;
};
const toNativeDate = date => {
if (isGregorian) return new Date(date.year, date.month - 1, date.day);
const gregorian = jalaali.toGregorian(...toExtendedDay(date));
return new Date(gregorian.gy, gregorian.gm - 1, gregorian.gd);
};