I'm building an NSPredicateEditor
, and I want the ability to do advanced date comparison.
I realize that I can build an NSPredicateEditorRowTemplate
with a rightExpressionType
of NSDateAttributeType
, but the predicates I want to build need to be much more advanced than that.
For example, I need to basic comparison like:
dateKeypath < aDate
dateKeypath <= aDate
dateKeypath = aDate
dateKeypath != aDate
dateKeypath > aDate
dateKeypath >= aDate
These basic comparisons are quite easy to achieve, and I have these working. However, I also need to do comparisons like:
dateKeypath isInTheLast n days
(or weeks, months, years)dateKeypath isNotInTheLast n days
(or weeks, months, years)dateKeypath between aDate and anotherDate
How can I achieve these sorts of comparisons? I understand that I'll need to create a custom NSPredicateEditorRowTemplate
, but I haven't found any clear documentation on how to achieve something like this.
EDIT
Bonus points are available for also knowing how to make these comparisons a full date-time (year-month-day-hour-minute-second) comparison (as NSDateAttributeType
only has year-month-day granularity).