diff --git a/ChangeLog b/ChangeLog index 81f842a4c..0f510911a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2002-11-01 Richard Frith-Macdonald + + * Headers/gnustep/base/NSDate.h: Added NSTimeIntervalSince1970 and + removed GSTimeNow() from public API. + * Source/NSDate.m: Update to use NSTimeIntervalSince1970 + * Source/NSTimer.m: Declare GSTimeNow() locally + * Source/NSprocessInfo.m: ditto + Thu Oct 31 00:46:23 2002 Nicola Pero * Headers/gnustep/base/NSBundle.h: Added more documentation. diff --git a/Headers/gnustep/base/NSDate.h b/Headers/gnustep/base/NSDate.h index fa5badeb5..3588034c4 100644 --- a/Headers/gnustep/base/NSDate.h +++ b/Headers/gnustep/base/NSDate.h @@ -21,9 +21,23 @@ #ifndef __NSDate_h_GNUSTEP_BASE_INCLUDE #define __NSDate_h_GNUSTEP_BASE_INCLUDE -/* Time interval difference between two dates, in seconds.*/ +#include + +/** + * Time interval difference between two dates, in seconds. + */ typedef double NSTimeInterval; +/** + * Time interval between the unix standard reference date of 1 January 1970 + * and the OpenStep reference date of 1 January 2001
+ * This number comes from:
+ * (((31 years * 365 days) + 8 days for leap years) = total number of days
+ * 24 hours * 60 minutes * 60 seconds)
+ * This ignores leap-seconds. + */ +GS_EXPORT const NSTimeInterval NSTimeIntervalSince1970; + #include @class NSArray; @@ -96,8 +110,4 @@ typedef double NSTimeInterval; @end -#ifndef NO_GNUSTEP -NSTimeInterval GSTimeNow(); /* Get time since reference date*/ -#endif - #endif /* __NSDate_h_GNUSTEP_BASE_INCLUDE*/ diff --git a/Source/NSDate.m b/Source/NSDate.m index 02f3f6c42..7d101d2c3 100644 --- a/Source/NSDate.m +++ b/Source/NSDate.m @@ -50,20 +50,13 @@ #include #include "GSPrivate.h" -/* The number of seconds between 1/1/2001 and 1/1/1970 = -978307200. */ -/* This number comes from: --(((31 years * 365 days) + 8 days for leap years) =total number of days - * 24 hours - * 60 minutes - * 60 seconds) - This ignores leap-seconds. */ -#define UNIX_REFERENCE_INTERVAL -978307200.0 - /* I hope 100,000 years is distant enough. */ #define DISTANT_YEARS 100000.0 #define DISTANT_FUTURE (DISTANT_YEARS * 365.0 * 24 * 60 * 60) #define DISTANT_PAST (-DISTANT_FUTURE) +const NSTimeInterval NSTimeIntervalSince1970 = 978307200.0; + static BOOL debug = NO; @@ -138,7 +131,7 @@ GSTimeNow() struct timeval tp; gettimeofday (&tp, NULL); - interval = UNIX_REFERENCE_INTERVAL; + interval = -NSTimeIntervalSince1970; interval += tp.tv_sec; interval += (double)tp.tv_usec / 1000000.0; return interval; @@ -922,7 +915,7 @@ GSTimeNow() + (id) dateWithTimeIntervalSince1970: (NSTimeInterval)seconds { return AUTORELEASE([[self alloc] initWithTimeIntervalSinceReferenceDate: - UNIX_REFERENCE_INTERVAL + seconds]); + -NSTimeIntervalSince1970 + seconds]); } + (id) dateWithTimeIntervalSinceReferenceDate: (NSTimeInterval)seconds @@ -1043,7 +1036,7 @@ GSTimeNow() - (id) initWithTimeIntervalSince1970: (NSTimeInterval)seconds { return [self initWithTimeIntervalSinceReferenceDate: - UNIX_REFERENCE_INTERVAL + seconds]; + -NSTimeIntervalSince1970 + seconds]; } - (id) initWithTimeIntervalSinceReferenceDate: (NSTimeInterval)secs @@ -1121,7 +1114,7 @@ GSTimeNow() - (NSTimeInterval) timeIntervalSince1970 { - return otherTime(self) - UNIX_REFERENCE_INTERVAL; + return otherTime(self) + NSTimeIntervalSince1970; } - (NSTimeInterval) timeIntervalSinceDate: (NSDate*)otherDate @@ -1248,7 +1241,7 @@ GSTimeNow() - (NSTimeInterval) timeIntervalSince1970 { - return _seconds_since_ref - UNIX_REFERENCE_INTERVAL; + return _seconds_since_ref + NSTimeIntervalSince1970; } - (NSTimeInterval) timeIntervalSinceDate: (NSDate*)otherDate diff --git a/Source/NSProcessInfo.m b/Source/NSProcessInfo.m index 59da9f220..d109dd1f9 100644 --- a/Source/NSProcessInfo.m +++ b/Source/NSProcessInfo.m @@ -615,6 +615,8 @@ int main(int argc, char *argv[], char *env[]) [gnustep_global_lock lock]; if (host == nil) { + extern NSTimeInterval GSTimeNow(); + pid = [self processIdentifier]; start = (unsigned long)GSTimeNow(); host = [[self hostName] stringByReplacingString: @"." withString: @"_"]; diff --git a/Source/NSTimer.m b/Source/NSTimer.m index 081a17e5b..04a631402 100644 --- a/Source/NSTimer.m +++ b/Source/NSTimer.m @@ -201,6 +201,7 @@ static Class NSDate_class; } else if (_invalidated == NO) { + extern NSTimeInterval GSTimeNow(); NSTimeInterval now = GSTimeNow(); NSTimeInterval nxt = [_date timeIntervalSinceReferenceDate]; int inc = -1;