-
Notifications
You must be signed in to change notification settings - Fork 919
Expand file tree
/
Copy pathscript.js
More file actions
39 lines (34 loc) · 1.28 KB
/
script.js
File metadata and controls
39 lines (34 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
function onSubmit() {
// Cutoff time for submission in CST.
var cutoffTime = "20:00:00";
// Get the current date and time in CST
var currentDate = new Date();
var currentCSTDate = new Date(
currentDate.toLocaleString("en-US", {
timeZone: "America/Chicago"
})
);
// Get time from current CST date
var currentCSTTime = currentCSTDate.toTimeString().substring(0, 8);
// Get last day of the month
var dayOfMonth = currentCSTDate.getDate();
var lastDayOfMonth = new Date(
currentCSTDate.getFullYear(),
currentCSTDate.getMonth() + 1,
0
).getDate();
if ((dayOfMonth === 16 || dayOfMonth === lastDayOfMonth) && currentCSTTime > cutoffTime) {
var workDate = g_form.getValue("work_date");
if (workDate) {
var formattedWorkDate = new Date(workDate + "T00:00:00");
// If work_date is on or before current date, block submission
if (formattedWorkDate <= currentCSTDate) {
g_form.addErrorMessage(
"The time period closed for time submission at 8:00 PM CST. Time must be billed in the next time period." + ": " + lastDayOfMonth
);
return false;
}
}
}
return true;
}