int Date_compare(const Date *self, const Date *other) { double s1 = Date_asSeconds(self); double s2 = Date_asSeconds(other); if (s1 == s2) { return 0; } return s1 > s2 ? 1 : -1; }
void Date_convertToTimeZone_(Date *self, struct timezone tz) { double s = Date_asSeconds(self) + ((self->tz.tz_minuteswest - tz.tz_minuteswest) * 60); Date_fromSeconds_(self, s); Date_setTimeZone_(self, tz); }
void Date_convertToTimeZone_(Date *self, struct timezone tz) { double s = Date_asSeconds(self) + 60*(self->tz.tz_minuteswest - (self->tz.tz_dsttime ? 60 : 0)) - 60*(tz.tz_minuteswest - (tz.tz_dsttime ? 60 : 0)); Date_fromSeconds_(self, s); Date_setTimeZone_(self, tz); }
IO_METHOD(IoDate, asNumber) { /*doc Date asNumber Returns the date as seconds since 1970 UTC. */ return IONUMBER(Date_asSeconds(DATA(self))); }