last working day of the month

PHOTO EMBED

Thu Oct 21 2021 07:35:35 GMT+0000 (UTC)

Saved by @mathiasVDD #javascript

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;
content_copyCOPY