function isLastWorkingDay(gdt) { var today = gdt.getDayOfWeekLocalTime(); var thisMonth = gdt.getMonthLocalTime(); switch (today) { // Saturday and Sunday are NOT the last working day of the month case 6: case 7: return false; break; // If it's a Friday, add 3 and see if the month changes. case 5: var nextMonday = gdt; nextMonday.addDaysLocalTime(3); var nextMondayMonth = nextMonday.getMonthLocalTime(); return (nextMondayMonth != thisMonth); break; // If it's a Mon-Thu add one and see if the month changes default: var nextDay = gdt; nextDay.addDaysLocalTime(1); var nextDayMonth = nextDay.getMonthLocalTime(); return (nextDayMonth != thisMonth); break; } } var now = new GlideDateTime(); var lwd = isLastWorkingDay(now); answer = lwd; answer;
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter