// Get form fields const { dob_month, dob_day, dob_year, working, seen_doctor, have_attorney, have_applied } = feathery.getFieldValues(); // Calculate age based on DOB const birthDate = new Date(dob_year, dob_month - 1, dob_day); const today = new Date(); let age = today.getFullYear() - birthDate.getFullYear(); const monthDifference = today.getMonth() - birthDate.getMonth(); if (monthDifference < 0 || (monthDifference === 0 && today.getDate() < birthDate.getDate())) { age--; } // Set the calculated age to the 'age' field feathery.setFieldValues({ age: age }); // Check current time and day const currentHour = today.getUTCHours() - 5; // Convert UTC to Eastern Time const currentDay = today.getUTCDay(); // 0 is Sunday, 1 is Monday, etc. // First Button Logic if ( (age >= 49 && age <= 62) && (working === "part time" || working === "not working") && seen_doctor === "yes" && (have_attorney === "no" || have_attorney === "had") && (have_applied === "first time" || have_applied === "previous") ) { if ((currentHour >= 9 && currentHour < 19) && (currentDay >= 1 && currentDay <= 5)) { // 9am-7pm EST Monday-Friday location.href = 'https://www.ssdi-approvals.com/thank-you-p'; } else { location.href = 'https://www.ssdi-approvals.com/thank-you-p2'; } } // Second Button Logic (for the leftovers) else { location.href = 'https://www.ssdi-approvals.com/thank-you-np'; }