Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
TryCF Gist
date = now();
date = dateAdd('d', 100, date)
writedump(DatePart('y', date))
lastScheduled = now();
currentDate = now();
scheduleType = 'd';
coupon = {
"scheduled" = true,
"scheduledType" = "d",
"schedulerLastExecuted" = ""
runScheduler= runSchedulerForCoupon(coupon=coupon);
<cffunction name="runSchedulerForCoupon" returnType="boolean">
<cfargument name="coupon" type="struct" required="true">
var dateNow = now();
return false;
if(NOT isDefinied("") OR EQ ""){
return true;
case "d":
return DatePart('y', dateNow) GT DatePart('y',;
case "w":
return DatePart('y', - DatePart('y', dateNow) GTE 7;
case "m":
var isNextMonth = DatePart('m', dateNow) GT DatePart('m',;
var daysInMonth = 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