Example #1
0
double Date_secondsSinceNow(const Date *self)
{
    Date *now = Date_new();
    double s = Date_secondsSince_(now, self);
    Date_free(now);
    return s;
}
Example #2
0
File: IoDate.c Project: bomma/io
IO_METHOD(IoDate, secondsSince_)
{
	/*doc Date secondsSince(aDate)
	Returns a number of seconds of between aDate and the receiver. 
	*/

	IoDate *date = IoMessage_locals_dateArgAt_(m, locals, 0);
	return IONUMBER(Date_secondsSince_(DATA(self), DATA(date)));
}
Example #3
0
File: IoDate.c Project: 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);
}
Example #4
0
Duration *Date_newDurationBySubtractingDate_(const Date *self, const Date *other)
{
    double d = Date_secondsSince_(self, other);
    return Duration_newWithSeconds_(d);
}