-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshiftCheck.osts
More file actions
1 lines (1 loc) · 1.88 KB
/
shiftCheck.osts
File metadata and controls
1 lines (1 loc) · 1.88 KB
1
{"version":"0.3.0","body":"function main(workbook: ExcelScript.Workbook) {\n // Define the cell to change based on time\n let sheet = workbook.getWorksheet(\"PHONE 6.100 AC-PC\");\n\n const protection = sheet.getProtection();\n\n const password: string = \"imsorrydave\";\n\n protection.pauseProtection();\n\n let cell = sheet.getRange(\"C5\"); // Change this to the desired cell\n\n cell.setNumberFormat(\"h AM/PM\");\n\n // Get the current date and time\n let currentDate = new Date();\n let currentHour = currentDate.getHours();\n\n \n\n // Check if it is 7 AM or 7 PM\n if (currentHour >= 7 && currentHour <= 18.59) {\n cell.setValue(\"7 AM\"); // Change this value as needed for 7 AM\n } else if (currentHour => 19 && currentHour <= 7 ) {\n cell.setValue(\"7 PM\"); // Change this value as needed for 7 PM\n } \n ;\n\n protection.protect();\n \n };\n\n// Helper function to format date as yyyy-mm-dd\nfunction formatDate(date: Date): string {\n let year = date.getFullYear();\n let month = ('0' + (date.getMonth() + 1)).slice(-2);\n let day = ('0' + date.getDate()).slice(-2);\n return `${year}-${month}-${day}`;\n}\n\n// Helper function to format time as hh:mm:ss\nfunction formatTime(date: Date): string {\n let hours = ('0' + date.getHours()).slice(-2);\n let minutes = ('0' + date.getMinutes()).slice(-2);\n let seconds = ('0' + date.getSeconds()).slice(-2);\n return `${hours}:${minutes}:${seconds}`;\n}\n","description":"","noCodeMetadata":null,"parameterInfo":"{\"version\":1,\"originalParameterOrder\":[],\"parameterSchema\":{\"type\":\"object\",\"default\":{},\"x-ms-visibility\":\"internal\"},\"returnSchema\":{\"type\":\"object\",\"properties\":{}},\"signature\":{\"comment\":\"\",\"parameters\":[{\"name\":\"workbook\",\"comment\":\"\"}]}}","apiInfo":"{\"variant\":\"synchronous\",\"variantVersion\":2}"}