示例#1
0
文件: IoDate.c 项目: bomma/io
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);
}
示例#2
0
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;
}
示例#3
0
文件: IoDate.c 项目: bomma/io
int IoDate_compare(IoDate *self, IoDate *date)
{
	if (ISDATE(date)) return Date_compare(DATA(self), DATA(date));
	return IoObject_defaultCompare(self, date);
}