IO_METHOD(IoDate, subtract) { /*doc Date -(aDurationOrDate) Return a new Date with the receiver's value minus an amount of time specified by aDuration to the receiver. Returns self. */ IoObject *v = IoMessage_locals_valueArgAt_(m, locals, 0); if (ISDATE(v)) { double d = Date_secondsSince_(DATA(self), DATA(v)); return IoDuration_newWithSeconds_(IOSTATE, d); } else if (ISDURATION(v)) { IoDate *newDate = IOCLONE(self); Date_subtractDuration_(DATA(newDate), IoDuration_duration(v)); return newDate; } IOASSERT(1, "Date or Duration argument required"); return IONIL(self); }
IoObject *IoMessage_locals_dateArgAt_(IoMessage *self, IoObject *locals, int n) { IoObject *v = IoMessage_locals_valueArgAt_(self, locals, n); if (!ISDATE(v)) IoMessage_locals_numberArgAt_errorForType_(self, locals, n, "Date"); return v; }
int IoDate_compare(IoDate *self, IoDate *date) { if (ISDATE(date)) return Date_compare(DATA(self), DATA(date)); return IoObject_defaultCompare(self, date); }