]> err.no Git - sope/blob - libFoundation/Foundation/NSConcreteDate.m
fixed some NGMail framework build issue
[sope] / libFoundation / Foundation / NSConcreteDate.m
1 /* 
2    NSConcreteDate.m
3
4    Copyright (C) 1995, 1996 Ovidiu Predescu and Mircea Oancea.
5    All rights reserved.
6
7    Author: Mircea Oancea <mircea@jupiter.elcom.pub.ro>
8
9    This file is part of libFoundation.
10
11    Permission to use, copy, modify, and distribute this software and its
12    documentation for any purpose and without fee is hereby granted, provided
13    that the above copyright notice appear in all copies and that both that
14    copyright notice and this permission notice appear in supporting
15    documentation.
16
17    We disclaim all warranties with regard to this software, including all
18    implied warranties of merchantability and fitness, in no event shall
19    we be liable for any special, indirect or consequential damages or any
20    damages whatsoever resulting from loss of use, data or profits, whether in
21    an action of contract, negligence or other tortious action, arising out of
22    or in connection with the use or performance of this software.
23 */
24
25 #include <Foundation/common.h>
26 #include <Foundation/NSString.h>
27 #include <Foundation/NSException.h>
28
29 #include "NSConcreteDate.h"
30
31 @implementation NSConcreteDate
32
33 - initWithTimeIntervalSinceReferenceDate:(NSTimeInterval)secsToBeAdded
34 {
35     [super init];
36     timeSinceRef = secsToBeAdded;
37     return self;
38 }
39
40 - init
41 {
42     [super init];
43     timeSinceRef = [NSDate timeIntervalSinceReferenceDate];
44     return self;
45 }
46
47 - (id)copyWithZone:(NSZone *)zone
48 {
49     if ([self zone] == zone)
50         return RETAIN(self);
51     return [[[self class] allocWithZone:zone]
52                 initWithTimeIntervalSinceReferenceDate:timeSinceRef];
53 }
54
55 - (NSTimeInterval)timeIntervalSinceReferenceDate
56 {
57     return timeSinceRef;
58 }
59
60 - (void)setTimeIntervalSinceReferenceDate:(NSTimeInterval)secsToBeAdded
61 {
62     timeSinceRef = secsToBeAdded;
63 }
64
65 - (NSComparisonResult)compare:(NSDate*)other
66 {
67     if ([other isKindOfClass:[NSDate class]]) {
68         NSTimeInterval diff
69             = timeSinceRef - [other timeIntervalSinceReferenceDate];
70
71         return (diff < 0 ?
72                   NSOrderedAscending
73                 : (diff == 0 ? NSOrderedSame : NSOrderedDescending));
74     }
75
76     NSAssert(0, @"Cannot compare NSDate with %@", [other class]);
77     return NSOrderedSame;
78 }
79
80 @end
81 /*
82   Local Variables:
83   c-basic-offset: 4
84   tab-width: 8
85   End:
86 */
87