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, fromNumber) { /*doc Date fromNumber(aNumber) Sets the receiver to be aNumber seconds since 1970. */ Date_fromSeconds_(DATA(self), IoMessage_locals_doubleArgAt_(m, locals, 0)); IoObject_isDirty_(self, 1); return self; }
void Date_fromString_format_(Date *self, const char *s, const char *format) { struct tm tm = EmptyTM(); io_strptime((char *)s, (char *)format, &tm); /* printf("year = %i\n", t.tm_year); printf("month = %i\n", t.tm_mon); printf("day = %i\n", t.tm_mday); printf("hour = %i\n", t.tm_hour); printf("min = %i\n", t.tm_min); printf("sec = %i\n", t.tm_sec); */ Date_fromSeconds_(self, mktime(&tm)); }
void Date_fromTime_(Date *self, time_t t) { Date_fromSeconds_(self, (double)t); }