Hi all,
I am trying to understand how ISC handles timezones when evaluating dates in Lifecycle State transforms.
In some cases, I had to add an extra day to the comparison (for example, using endDate + 3d instead of endDate + 2d) to keep a user in the expected state for the full grace period. Also, the operator does not change the situation either (lt, lte, gt, gte).
This makes me wonder how ISC evaluates date-only values after they are converted to ISO8601:
- Does ISC always treat these dates as midnight (
00:00:00) UTC? - Is there any recommended approach for implementing grace periods (for example, comparing
nowagainstendDate + X daysversus comparingnow - X daysagainstendDate) to avoid off-by-one-day issues?
Here an extract of the transform that I had to adjust in order to keep the business’s logic valid.
The expected logic is:
Active: startDate <= now <= endDate
Disabled: endDate < now <= endDate + 2 days
Terminated: now > endDate + 2 days
This is part of the condition:
#elseif($isAfterOrOnStartDate=='yes' && ($isBeforeOrOnEndDate=='yes' || $endDate=='N/A'))active#elseif($isAfterEndDate=='yes' && $grace_period=='yes')disabled#elseif($grace_period=='no' && $endDate != 'N/A')terminated#end"
Here a part where I add to add a day to make sure that the identity stayed in the state active even the last day of work:
"isBeforeOrOnEndDate": {
"type": "firstValid",
"attributes": {
"values": [
{
"type": "dateCompare",
"attributes": {
"firstDate": "now",
"secondDate": {
"type": "dateMath",
"attributes": {
"expression": "+1d",
"input": {
"type": "dateFormat",
"attributes": {
"input": {
"type": "identityAttribute",
"attributes": {
"name": "endDate"
}
},
"inputFormat": "yyyy-MM-dd",
"outputFormat": "ISO8601"
}
}
}
},
"operator": "lt",
"positiveCondition": "yes",
"negativeCondition": "no"
}
},
"N/A"
]
}
},
Same scenario, but for the disabled state:
"grace_period": {
"type": "firstValid",
"attributes": {
"values": [
{
"type": "dateCompare",
"attributes": {
"requiresPeriodicRefresh": true,
"firstDate": "now",
"secondDate": {
"type": "dateMath",
"attributes": {
"expression": "+3d",
"input": {
"type": "dateFormat",
"attributes": {
"input": {
"type": "identityAttribute",
"attributes": {
"name": "endDate"
}
},
"inputFormat": "yyyy-MM-dd",
"outputFormat": "ISO8601"
}
}
}
},
"operator": "lt",
"positiveCondition": "yes",
"negativeCondition": "no"
}
},
"N/A"
]
}
},
Thank you.