int IoDuration_compare(IoDuration *self, IoDuration *other) { if (ISDURATION(other)) { return Duration_compare(DATA(self), DATA(other)); } return IoObject_defaultCompare(self, other); }
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); }
IoDuration *IoMessage_locals_durationArgAt_(IoMessage *self, void *locals, int n) { IoObject *v = IoMessage_locals_valueArgAt_(self, (IoObject *)locals, n); if (!ISDURATION(v)) IoMessage_locals_numberArgAt_errorForType_(self, (IoObject *)locals, n, "Duration"); return v; }