Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
TryCF Gist
lastExecuted = dateAdd('y', -66, now());
coupon = {
"scheduled" = true,
"scheduledType" = "w",
"schedulerLastExecuted" = lastExecuted
runScheduler= runSchedulerForCoupon(coupon=coupon);
<cffunction name="runSchedulerForCoupon" returnType="boolean">
<cfargument name="coupon" type="struct" required="true">
var dateNow = now();
return false;
if(NOT isDefined("") OR EQ ""){
return true;
case "d":
return DatePart('y', dateNow) GT DatePart('y',;
case "w":
return Abs(DateDiff('d', dateNow, GTE 7;
case "m":
var isNextMonth = DatePart('m', dateNow) GT DatePart('m',;
return Abs(DateDiff('d', dateNow, GTE DaysInMonth(dateNow);
return isNextMonth AND (DatePart('d', dateNow) GTE DatePart('d', OR DatePart('d', dateNow) GTE daysInMonth);
case "y":
var isNextYear = DatePart('yyyy', dateNow) GT DatePart('yyyy',;
return isNextYear AND (DatePart('y', EQ DatePart('y', dateNow) OR (DatePart('y', dateNow) - DatePart('y', GT 365));
return false;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment