mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 16:30:41 +00:00
Widened class cluster
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@4123 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
14cd4d7b21
commit
8cd3966b44
1 changed files with 140 additions and 8 deletions
148
Source/NSDate.m
148
Source/NSDate.m
|
@ -33,6 +33,7 @@
|
||||||
#include <Foundation/NSUserDefaults.h>
|
#include <Foundation/NSUserDefaults.h>
|
||||||
#include <Foundation/NSCharacterSet.h>
|
#include <Foundation/NSCharacterSet.h>
|
||||||
#include <Foundation/NSScanner.h>
|
#include <Foundation/NSScanner.h>
|
||||||
|
#include <base/behavior.h>
|
||||||
#include <base/fast.x>
|
#include <base/fast.x>
|
||||||
#ifndef __WIN32__
|
#ifndef __WIN32__
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
@ -57,11 +58,25 @@
|
||||||
#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)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static BOOL debug = NO;
|
static BOOL debug = NO;
|
||||||
static Class abstractClass = nil;
|
static Class abstractClass = nil;
|
||||||
static Class concreteClass = nil;
|
static Class concreteClass = nil;
|
||||||
static Class calendarClass = nil;
|
static Class calendarClass = nil;
|
||||||
|
|
||||||
|
@interface GSDateSingle : NSGDate
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface GSDatePast : GSDateSingle
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface GSDateFuture : GSDateSingle
|
||||||
|
@end
|
||||||
|
|
||||||
|
static NSDate *_distantPast = nil;
|
||||||
|
static NSDate *_distantFuture = nil;
|
||||||
|
|
||||||
|
|
||||||
static NSString*
|
static NSString*
|
||||||
findInArray(NSArray *array, unsigned pos, NSString *str)
|
findInArray(NSArray *array, unsigned pos, NSString *str)
|
||||||
|
@ -833,18 +848,16 @@ GSTimeNow()
|
||||||
|
|
||||||
+ (id) distantFuture
|
+ (id) distantFuture
|
||||||
{
|
{
|
||||||
static id df = nil;
|
if (_distantFuture == nil)
|
||||||
if (!df)
|
return [GSDateFuture allocWithZone: 0];
|
||||||
df = [[self alloc] initWithTimeIntervalSinceReferenceDate: DISTANT_FUTURE];
|
return _distantFuture;
|
||||||
return df;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (id) distantPast
|
+ (id) distantPast
|
||||||
{
|
{
|
||||||
static id dp = nil;
|
if (_distantPast == nil)
|
||||||
if (!dp)
|
return [GSDatePast allocWithZone: 0];
|
||||||
dp = [[self alloc] initWithTimeIntervalSinceReferenceDate: DISTANT_PAST];
|
return _distantPast;
|
||||||
return dp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) copyWithZone: (NSZone*)zone
|
- (id) copyWithZone: (NSZone*)zone
|
||||||
|
@ -1178,3 +1191,122 @@ GSTimeNow()
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This abstract class represents a date of which there can be only
|
||||||
|
* one instance.
|
||||||
|
*/
|
||||||
|
@implementation GSDateSingle
|
||||||
|
|
||||||
|
+ (void) initialize
|
||||||
|
{
|
||||||
|
if (self == [GSDateSingle class])
|
||||||
|
{
|
||||||
|
[self setVersion: 1];
|
||||||
|
behavior_class_add_class(self, [NSGDate class]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (Class) classForPortCoder
|
||||||
|
{
|
||||||
|
return [self class];
|
||||||
|
}
|
||||||
|
|
||||||
|
- replacementObjectForPortCoder: aRmc
|
||||||
|
{
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) encodeWithCoder: (NSCoder*)coder
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) initWithCoder: (NSCoder*)coder
|
||||||
|
{
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) autorelease
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) release
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) retain
|
||||||
|
{
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) allocWithZone: (NSZone*)z
|
||||||
|
{
|
||||||
|
[NSException raise: NSInternalInconsistencyException
|
||||||
|
format: @"Attempt to allocate fixed date"];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) copyWithZone: (NSZone*)z
|
||||||
|
{
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) dealloc
|
||||||
|
{
|
||||||
|
[NSException raise: NSInternalInconsistencyException
|
||||||
|
format: @"Attempt to deallocate fixed date"];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) initWithTimeIntervalSinceReferenceDate: (NSTimeInterval)secs
|
||||||
|
{
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@implementation GSDatePast
|
||||||
|
|
||||||
|
+ (id) allocWithZone: (NSZone*)z
|
||||||
|
{
|
||||||
|
if (_distantPast == nil)
|
||||||
|
{
|
||||||
|
id obj = NSAllocateObject(self, 0, NSDefaultMallocZone());
|
||||||
|
|
||||||
|
_distantPast = [obj init];
|
||||||
|
}
|
||||||
|
return _distantPast;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) initWithTimeIntervalSinceReferenceDate: (NSTimeInterval)secs
|
||||||
|
{
|
||||||
|
seconds_since_ref = DISTANT_PAST;
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
@implementation GSDateFuture
|
||||||
|
|
||||||
|
+ (id) allocWithZone: (NSZone*)z
|
||||||
|
{
|
||||||
|
if (_distantFuture == nil)
|
||||||
|
{
|
||||||
|
id obj = NSAllocateObject(self, 0, NSDefaultMallocZone());
|
||||||
|
|
||||||
|
_distantFuture = [obj init];
|
||||||
|
}
|
||||||
|
return _distantFuture;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) initWithTimeIntervalSinceReferenceDate: (NSTimeInterval)secs
|
||||||
|
{
|
||||||
|
seconds_since_ref = DISTANT_FUTURE;
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue