Portions of the NSDate implementation are derived from
public domain software described in
``Calendrical Calculations'' by Nachum Dershowitz and
Edward M. Reingold, Software---Practice & Experience,
vol. 20, no. 9 (September, 1990), pp. 899--928 and from
``Calendrical Calculations, II: Three Historical Calendars''
by Edward M. Reingold, Nachum Dershowitz, and Stewart M. Clamen,
Software---Practice & Experience, vol. 23, to appear.
*/
#import <Foundation/NSObject.h>
@class NSString, NSArray, NSDictionary;
/* This module implements the 'date and time' concept. Features:
- it is easy to compare dates and deal with time intervals;
- fast (can use the native representation);
- accuracy (other date representations can be added to the framework);
- can support user-oriented representations (Gregorian, etc ...);
- dates are immutable;
- an absolute reference date to ease conversion to other representations;
Our absolute reference date is the first instant of Jan 1st, 2001.
All representations must be able to convert to/from that absolute reference.
We ignore leap second accounting (e.g. pretend that they don't happen).
Our reference date corresponds to 978307200 seconds after the UNIX base (e.g.
1/1/1970 to 1/1/2001 is (31*365 + 8 (leaps: 1972, .., 2000))*24*60*60)
Other interesting numbers are the number of days to the Common Era 1/1/1 ((2000*365+25*20-20+5+1), and for astronomers, from there to the Julian Epoch, 1721425.5.
*/
typedef double NSTimeInterval;
/* always in seconds;
yields sub-millisecond precision over a range of 10000 years */
#define NSTimeIntervalSince1970 978307200.0L
@class NSCalendarDate; // expresses Western dates (see below)
@class NSTimeZone; // expresses a time zone (see below)
Conversion between two dates using the same representation should be exact */
- (NSTimeInterval)timeIntervalSinceNow;
/* >0 if self is in the future */
- (NSTimeInterval)timeIntervalSince1970;
/* convenience for POSIX calculations; neg if date is before 1970 */
- (id)addTimeInterval:(NSTimeInterval)seconds;
/* Returns an auto-released date;
may return a date from a different representation */
- (NSDate *)earlierDate:(NSDate *)anotherDate;
- (NSDate *)laterDate:(NSDate *)anotherDate;
- (NSComparisonResult)compare:(NSDate *)other;
- (BOOL)isEqualToDate:(NSDate *)otherDate;
+ (NSTimeInterval)timeIntervalSinceReferenceDate;
@end
/*************** Creation of basic dates ***************/
@interface NSDate (NSDateCreation)
+ (id)allocWithZone:(NSZone *)zone;
/* Create an uninitialized instance of a concrete date;
When called with NSDate, substitutes a concrete class that guarantees a wide dynamic range, but as accurate as possible for dates close to boot time for use in timers;