mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 16:30:41 +00:00
Date tidyups
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@14897 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
63c30b8c40
commit
96f7c6fab1
5 changed files with 33 additions and 19 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2002-11-01 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* 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 <n.pero@mi.flashnet.it>
|
Thu Oct 31 00:46:23 2002 Nicola Pero <n.pero@mi.flashnet.it>
|
||||||
|
|
||||||
* Headers/gnustep/base/NSBundle.h: Added more documentation.
|
* Headers/gnustep/base/NSBundle.h: Added more documentation.
|
||||||
|
|
|
@ -21,9 +21,23 @@
|
||||||
#ifndef __NSDate_h_GNUSTEP_BASE_INCLUDE
|
#ifndef __NSDate_h_GNUSTEP_BASE_INCLUDE
|
||||||
#define __NSDate_h_GNUSTEP_BASE_INCLUDE
|
#define __NSDate_h_GNUSTEP_BASE_INCLUDE
|
||||||
|
|
||||||
/* Time interval difference between two dates, in seconds.*/
|
#include <Foundation/NSObjCRuntime.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Time interval difference between two dates, in seconds.
|
||||||
|
*/
|
||||||
typedef double NSTimeInterval;
|
typedef double NSTimeInterval;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Time interval between the unix standard reference date of 1 January 1970
|
||||||
|
* and the OpenStep reference date of 1 January 2001<br />
|
||||||
|
* This number comes from:<br />
|
||||||
|
* (((31 years * 365 days) + 8 days for leap years) = total number of days<br />
|
||||||
|
* 24 hours * 60 minutes * 60 seconds)<br />
|
||||||
|
* This ignores leap-seconds.
|
||||||
|
*/
|
||||||
|
GS_EXPORT const NSTimeInterval NSTimeIntervalSince1970;
|
||||||
|
|
||||||
#include <Foundation/NSObject.h>
|
#include <Foundation/NSObject.h>
|
||||||
|
|
||||||
@class NSArray;
|
@class NSArray;
|
||||||
|
@ -96,8 +110,4 @@ typedef double NSTimeInterval;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#ifndef NO_GNUSTEP
|
|
||||||
NSTimeInterval GSTimeNow(); /* Get time since reference date*/
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* __NSDate_h_GNUSTEP_BASE_INCLUDE*/
|
#endif /* __NSDate_h_GNUSTEP_BASE_INCLUDE*/
|
||||||
|
|
|
@ -50,20 +50,13 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "GSPrivate.h"
|
#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. */
|
/* I hope 100,000 years is distant enough. */
|
||||||
#define DISTANT_YEARS 100000.0
|
#define DISTANT_YEARS 100000.0
|
||||||
#define DISTANT_FUTURE (DISTANT_YEARS * 365.0 * 24 * 60 * 60)
|
#define DISTANT_FUTURE (DISTANT_YEARS * 365.0 * 24 * 60 * 60)
|
||||||
#define DISTANT_PAST (-DISTANT_FUTURE)
|
#define DISTANT_PAST (-DISTANT_FUTURE)
|
||||||
|
|
||||||
|
const NSTimeInterval NSTimeIntervalSince1970 = 978307200.0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static BOOL debug = NO;
|
static BOOL debug = NO;
|
||||||
|
@ -138,7 +131,7 @@ GSTimeNow()
|
||||||
struct timeval tp;
|
struct timeval tp;
|
||||||
|
|
||||||
gettimeofday (&tp, NULL);
|
gettimeofday (&tp, NULL);
|
||||||
interval = UNIX_REFERENCE_INTERVAL;
|
interval = -NSTimeIntervalSince1970;
|
||||||
interval += tp.tv_sec;
|
interval += tp.tv_sec;
|
||||||
interval += (double)tp.tv_usec / 1000000.0;
|
interval += (double)tp.tv_usec / 1000000.0;
|
||||||
return interval;
|
return interval;
|
||||||
|
@ -922,7 +915,7 @@ GSTimeNow()
|
||||||
+ (id) dateWithTimeIntervalSince1970: (NSTimeInterval)seconds
|
+ (id) dateWithTimeIntervalSince1970: (NSTimeInterval)seconds
|
||||||
{
|
{
|
||||||
return AUTORELEASE([[self alloc] initWithTimeIntervalSinceReferenceDate:
|
return AUTORELEASE([[self alloc] initWithTimeIntervalSinceReferenceDate:
|
||||||
UNIX_REFERENCE_INTERVAL + seconds]);
|
-NSTimeIntervalSince1970 + seconds]);
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (id) dateWithTimeIntervalSinceReferenceDate: (NSTimeInterval)seconds
|
+ (id) dateWithTimeIntervalSinceReferenceDate: (NSTimeInterval)seconds
|
||||||
|
@ -1043,7 +1036,7 @@ GSTimeNow()
|
||||||
- (id) initWithTimeIntervalSince1970: (NSTimeInterval)seconds
|
- (id) initWithTimeIntervalSince1970: (NSTimeInterval)seconds
|
||||||
{
|
{
|
||||||
return [self initWithTimeIntervalSinceReferenceDate:
|
return [self initWithTimeIntervalSinceReferenceDate:
|
||||||
UNIX_REFERENCE_INTERVAL + seconds];
|
-NSTimeIntervalSince1970 + seconds];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) initWithTimeIntervalSinceReferenceDate: (NSTimeInterval)secs
|
- (id) initWithTimeIntervalSinceReferenceDate: (NSTimeInterval)secs
|
||||||
|
@ -1121,7 +1114,7 @@ GSTimeNow()
|
||||||
|
|
||||||
- (NSTimeInterval) timeIntervalSince1970
|
- (NSTimeInterval) timeIntervalSince1970
|
||||||
{
|
{
|
||||||
return otherTime(self) - UNIX_REFERENCE_INTERVAL;
|
return otherTime(self) + NSTimeIntervalSince1970;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSTimeInterval) timeIntervalSinceDate: (NSDate*)otherDate
|
- (NSTimeInterval) timeIntervalSinceDate: (NSDate*)otherDate
|
||||||
|
@ -1248,7 +1241,7 @@ GSTimeNow()
|
||||||
|
|
||||||
- (NSTimeInterval) timeIntervalSince1970
|
- (NSTimeInterval) timeIntervalSince1970
|
||||||
{
|
{
|
||||||
return _seconds_since_ref - UNIX_REFERENCE_INTERVAL;
|
return _seconds_since_ref + NSTimeIntervalSince1970;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSTimeInterval) timeIntervalSinceDate: (NSDate*)otherDate
|
- (NSTimeInterval) timeIntervalSinceDate: (NSDate*)otherDate
|
||||||
|
|
|
@ -615,6 +615,8 @@ int main(int argc, char *argv[], char *env[])
|
||||||
[gnustep_global_lock lock];
|
[gnustep_global_lock lock];
|
||||||
if (host == nil)
|
if (host == nil)
|
||||||
{
|
{
|
||||||
|
extern NSTimeInterval GSTimeNow();
|
||||||
|
|
||||||
pid = [self processIdentifier];
|
pid = [self processIdentifier];
|
||||||
start = (unsigned long)GSTimeNow();
|
start = (unsigned long)GSTimeNow();
|
||||||
host = [[self hostName] stringByReplacingString: @"." withString: @"_"];
|
host = [[self hostName] stringByReplacingString: @"." withString: @"_"];
|
||||||
|
|
|
@ -201,6 +201,7 @@ static Class NSDate_class;
|
||||||
}
|
}
|
||||||
else if (_invalidated == NO)
|
else if (_invalidated == NO)
|
||||||
{
|
{
|
||||||
|
extern NSTimeInterval GSTimeNow();
|
||||||
NSTimeInterval now = GSTimeNow();
|
NSTimeInterval now = GSTimeNow();
|
||||||
NSTimeInterval nxt = [_date timeIntervalSinceReferenceDate];
|
NSTimeInterval nxt = [_date timeIntervalSinceReferenceDate];
|
||||||
int inc = -1;
|
int inc = -1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue