/** * Update Event Logs convertedTime */ function convertToCST(utcTimestamp) { // Parse the UTC timestamp string into a Date object const date = new Date(utcTimestamp); // Check if daylight saving time (DST) is in effect const isDST = () => { const january = new Date(date.getFullYear(), 0, 1); const july = new Date(date.getFullYear(), 6, 1); return date.getTimezoneOffset() < Math.max(january.getTimezoneOffset(), july.getTimezoneOffset()); }; // Adjust the date for daylight saving time if (isDST()) { date.setHours(date.getHours() + 1); } // Convert to America/Chicago timezone const cstTime = new Intl.DateTimeFormat('en-US', { timeZone: 'America/Chicago', hour12: false, // 24-hour format year: 'numeric', month: 'numeric', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric', }).format(date); return cstTime; } angular .element('.unqorkio-form') .scope() .$watchGroup(["submission.data.eventLog"], (eventLogs, _) => { if (eventLogs == undefined) { return; } eventLogs[0].map((eventLog, i) => { angular.element('.unqorkio-form').scope().submission.data.eventLog[i].convertedTimeStamp = convertToCST(eventLog.created) + " CST"; }); });