@@ -48,98 +48,98 @@ static OFMutex *mutex; #endif #ifdef HAVE_GMTIME_R # define GMTIME_RET(field) \ - time_t seconds_ = (time_t)seconds; \ + time_t seconds = (time_t)_seconds; \ struct tm tm; \ \ - if (seconds_ != floor(seconds)) \ + if (seconds != floor(_seconds)) \ @throw [OFOutOfRangeException \ exceptionWithClass: [self class]]; \ \ - if (gmtime_r(&seconds_, &tm) == NULL) \ + if (gmtime_r(&seconds, &tm) == NULL) \ @throw [OFOutOfRangeException \ exceptionWithClass: [self class]]; \ \ return tm.field; # define LOCALTIME_RET(field) \ - time_t seconds_ = (time_t)seconds; \ + time_t seconds = (time_t)_seconds; \ struct tm tm; \ \ - if (seconds_ != floor(seconds)) \ + if (seconds != floor(_seconds)) \ @throw [OFOutOfRangeException \ exceptionWithClass: [self class]]; \ \ - if (localtime_r(&seconds_, &tm) == NULL) \ + if (localtime_r(&seconds, &tm) == NULL) \ @throw [OFOutOfRangeException \ exceptionWithClass: [self class]]; \ \ return tm.field; #else # ifdef OF_HAVE_THREADS # define GMTIME_RET(field) \ - time_t seconds_ = (time_t)seconds; \ + time_t seconds = (time_t)_seconds; \ struct tm *tm; \ \ - if (seconds_ != floor(seconds)) \ + if (seconds != floor(_seconds)) \ @throw [OFOutOfRangeException \ exceptionWithClass: [self class]]; \ \ [mutex lock]; \ \ @try { \ - if ((tm = gmtime(&seconds_)) == NULL) \ + if ((tm = gmtime(&seconds)) == NULL) \ @throw [OFOutOfRangeException \ exceptionWithClass: [self class]]; \ \ return tm->field; \ } @finally { \ [mutex unlock]; \ } # define LOCALTIME_RET(field) \ - time_t seconds_ = (time_t)seconds; \ + time_t seconds = (time_t)_seconds; \ struct tm *tm; \ \ - if (seconds_ != floor(seconds)) \ + if (seconds != floor(_seconds)) \ @throw [OFOutOfRangeException \ exceptionWithClass: [self class]]; \ \ [mutex lock]; \ \ @try { \ - if ((tm = localtime(&seconds_)) == NULL) \ + if ((tm = localtime(&seconds)) == NULL) \ @throw [OFOutOfRangeException \ exceptionWithClass: [self class]]; \ \ return tm->field; \ } @finally { \ [mutex unlock]; \ } # else # define GMTIME_RET(field) \ - time_t seconds_ = (time_t)seconds; \ + time_t seconds = (time_t)_seconds; \ struct tm *tm; \ \ - if (seconds_ != floor(seconds)) \ + if (seconds != floor(_seconds)) \ @throw [OFOutOfRangeException \ exceptionWithClass: [self class]]; \ \ - if ((tm = gmtime(&seconds_)) == NULL) \ + if ((tm = gmtime(&seconds)) == NULL) \ @throw [OFOutOfRangeException \ exceptionWithClass: [self class]]; \ \ return tm->field; # define LOCALTIME_RET(field) \ - time_t seconds_ = (time_t)seconds; \ + time_t seconds = (time_t)_seconds; \ struct tm *tm; \ \ - if (seconds_ != floor(seconds)) \ + if (seconds != floor(_seconds)) \ @throw [OFOutOfRangeException \ exceptionWithClass: [self class]]; \ \ - if ((tm = localtime(&seconds_)) == NULL) \ + if ((tm = localtime(&seconds)) == NULL) \ @throw [OFOutOfRangeException \ exceptionWithClass: [self class]]; \ \ return tm->field; # endif @@ -217,32 +217,32 @@ { struct timeval t; self = [super init]; - OF_ENSURE(!gettimeofday(&t, NULL)); + OF_ENSURE(gettimeofday(&t, NULL) == 0); - seconds = t.tv_sec; - seconds += (double)t.tv_usec / 1000000; + _seconds = t.tv_sec; + _seconds += (double)t.tv_usec / 1000000; return self; } -- initWithTimeIntervalSince1970: (double)seconds_ +- initWithTimeIntervalSince1970: (double)seconds { self = [super init]; - seconds = seconds_; + _seconds = seconds; return self; } -- initWithTimeIntervalSinceNow: (double)seconds_ +- initWithTimeIntervalSinceNow: (double)seconds { self = [self init]; - seconds += seconds_; + _seconds += seconds; return self; } - initWithDateString: (OFString*)string @@ -259,33 +259,33 @@ &tm) == NULL) @throw [OFInvalidFormatException exceptionWithClass: [self class]]; /* Years */ - seconds = (int64_t)(tm.tm_year - 70) * 31536000; + _seconds = (int64_t)(tm.tm_year - 70) * 31536000; /* Days of leap years, excluding the year to look at */ - seconds += (((tm.tm_year + 1899) / 4) - 492) * 86400; - seconds -= (((tm.tm_year + 1899) / 100) - 19) * 86400; - seconds += (((tm.tm_year + 1899) / 400) - 4) * 86400; + _seconds += (((tm.tm_year + 1899) / 4) - 492) * 86400; + _seconds -= (((tm.tm_year + 1899) / 100) - 19) * 86400; + _seconds += (((tm.tm_year + 1899) / 400) - 4) * 86400; /* Leap day */ if (tm.tm_mon >= 2 && (((tm.tm_year + 1900) % 4 == 0 && (tm.tm_year + 1900) % 100 != 0) || (tm.tm_year + 1900) % 400 == 0)) - seconds += 86400; + _seconds += 86400; /* Months */ if (tm.tm_mon < 0 || tm.tm_mon > 12) @throw [OFInvalidFormatException exceptionWithClass: [self class]]; - seconds += month_to_day_of_year[tm.tm_mon] * 86400; + _seconds += month_to_day_of_year[tm.tm_mon] * 86400; /* Days */ - seconds += (tm.tm_mday - 1) * 86400; + _seconds += (tm.tm_mday - 1) * 86400; /* Hours */ - seconds += tm.tm_hour * 3600; + _seconds += tm.tm_hour * 3600; /* Minutes */ - seconds += tm.tm_min * 60; + _seconds += tm.tm_min * 60; /* Seconds */ - seconds += tm.tm_sec; + _seconds += tm.tm_sec; } @catch (id e) { [self release]; @throw e; } @@ -305,11 +305,11 @@ if (of_strptime([string UTF8String], [format UTF8String], &tm) == NULL) @throw [OFInvalidFormatException exceptionWithClass: [self class]]; - if ((seconds = mktime(&tm)) == -1) + if ((_seconds = mktime(&tm)) == -1) @throw [OFInvalidFormatException exceptionWithClass: [self class]]; } @catch (id e) { [self release]; @throw e; @@ -334,11 +334,11 @@ @throw [OFInvalidArgumentException exceptionWithClass: [self class] selector: _cmd]; d.u = (uint64_t)[element hexadecimalValue]; - seconds = d.d; + _seconds = d.d; objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; @@ -354,11 +354,11 @@ if (![object isKindOfClass: [OFDate class]]) return NO; otherDate = object; - if (otherDate->seconds != seconds) + if (otherDate->_seconds != _seconds) return NO; return YES; } @@ -369,11 +369,11 @@ double d; uint8_t b[sizeof(double)]; } d; uint_fast8_t i; - d.d = OF_BSWAP_DOUBLE_IF_BE(seconds); + d.d = OF_BSWAP_DOUBLE_IF_BE(_seconds); OF_HASH_INIT(hash); for (i = 0; i < sizeof(double); i++) OF_HASH_ADD(hash, d.b[i]); @@ -397,13 +397,13 @@ exceptionWithClass: [self class] selector: _cmd]; otherDate = (OFDate*)object; - if (seconds < otherDate->seconds) + if (_seconds < otherDate->_seconds) return OF_ORDERED_ASCENDING; - if (seconds > otherDate->seconds) + if (_seconds > otherDate->_seconds) return OF_ORDERED_DESCENDING; return OF_ORDERED_SAME; } @@ -422,11 +422,11 @@ } d; element = [OFXMLElement elementWithName: [self className] namespace: OF_SERIALIZATION_NS]; - d.d = seconds; + d.d = _seconds; [element setStringValue: [OFString stringWithFormat: @"%016" PRIx64, d.u]]; [element retain]; @@ -435,11 +435,11 @@ return [element autorelease]; } - (uint32_t)microsecond { - return (uint32_t)rint((seconds - floor(seconds)) * 1000000); + return (uint32_t)rint((_seconds - floor(_seconds)) * 1000000); } - (uint8_t)second { GMTIME_RET(tm_sec) @@ -511,30 +511,30 @@ } - (OFString*)dateStringWithFormat: (OFConstantString*)format { OFString *ret; - time_t seconds_ = (time_t)seconds; + time_t seconds = (time_t)_seconds; struct tm tm; size_t pageSize; char *buffer; - if (seconds_ != floor(seconds)) + if (seconds != floor(_seconds)) @throw [OFOutOfRangeException exceptionWithClass: [self class]]; #ifdef HAVE_GMTIME_R - if (gmtime_r(&seconds_, &tm) == NULL) + if (gmtime_r(&seconds, &tm) == NULL) @throw [OFOutOfRangeException exceptionWithClass: [self class]]; #else # ifdef OF_HAVE_THREADS [mutex lock]; @try { # endif struct tm *tmp; - if ((tmp = gmtime(&seconds_)) == NULL) + if ((tmp = gmtime(&seconds)) == NULL) @throw [OFOutOfRangeException exceptionWithClass: [self class]]; tm = *tmp; # ifdef OF_HAVE_THREADS @@ -561,30 +561,30 @@ } - (OFString*)localDateStringWithFormat: (OFConstantString*)format { OFString *ret; - time_t seconds_ = (time_t)seconds; + time_t seconds = (time_t)_seconds; struct tm tm; size_t pageSize; char *buffer; - if (seconds_ != floor(seconds)) + if (seconds != floor(_seconds)) @throw [OFOutOfRangeException exceptionWithClass: [self class]]; #ifdef HAVE_LOCALTIME_R - if (localtime_r(&seconds_, &tm) == NULL) + if (localtime_r(&seconds, &tm) == NULL) @throw [OFOutOfRangeException exceptionWithClass: [self class]]; #else # ifdef OF_HAVE_THREADS [mutex lock]; @try { # endif struct tm *tmp; - if ((tmp = localtime(&seconds_)) == NULL) + if ((tmp = localtime(&seconds)) == NULL) @throw [OFOutOfRangeException exceptionWithClass: [self class]]; tm = *tmp; # ifdef OF_HAVE_THREADS @@ -632,31 +632,31 @@ return [[self retain] autorelease]; } - (double)timeIntervalSince1970 { - return seconds; + return _seconds; } - (double)timeIntervalSinceDate: (OFDate*)otherDate { - return seconds - otherDate->seconds; + return _seconds - otherDate->_seconds; } - (double)timeIntervalSinceNow { struct timeval t; - double seconds_; + double seconds; OF_ENSURE(!gettimeofday(&t, NULL)); - seconds_ = t.tv_sec; - seconds_ += (double)t.tv_usec / 1000000; + seconds = t.tv_sec; + seconds += (double)t.tv_usec / 1000000; - return seconds - seconds_; + return _seconds - seconds; } -- (OFDate*)dateByAddingTimeInterval: (double)seconds_ +- (OFDate*)dateByAddingTimeInterval: (double)seconds { - return [OFDate dateWithTimeIntervalSince1970: seconds + seconds_]; + return [OFDate dateWithTimeIntervalSince1970: _seconds + seconds]; } @end