I am using a custom script for locking timesheet, but users are changing their local date and time before the locking period and then fill the timesheet. How do we avoid it. Can someone suggest me how to fetch the current IST from web and then compare it in the below script?
frappe.ui.form.on("Timesheet", "validate", function(frm) {
if (frappe.user_roles.indexOf("Projects Manager") == -1) {
const t = new Date().getDate() + (6 - new Date().getDay()) - 7;
const lastSaturday = new Date();
lastSaturday.setDate(t);
let dd = lastSaturday.getDate();
let mm = lastSaturday.getMonth() + 1;
let yyyy = lastSaturday.getFullYear();
frm.doc.time_logs.forEach(log => {
if (new Date(log.from_time) <= lastSaturday) {
frappe.throw("You cannot add timesheet for dates before last Saturday " + dd + "/" + mm + "/" + yyyy);
}
})
}
})