home *** CD-ROM | disk | FTP | other *** search
/ OpenStep (Enterprise) / OpenStepENTCD.toast / OEDEV / DEV.Z / NSDate.h < prev    next >
Encoding:
Text File  |  1996-09-11  |  4.7 KB  |  165 lines

  1. /*    NSDate.h
  2.     Primitives for manipulating time
  3.     Copyright 1994-1996, NeXT Software, Inc.  All rights reserved.
  4. */
  5.  
  6. #import <Foundation/NSObject.h>
  7.  
  8. @class NSString, NSArray, NSDictionary, NSCalendarDate, NSTimeZone, NSTimeZoneDetail;
  9.  
  10. typedef double NSTimeInterval;
  11.  
  12. #define NSTimeIntervalSince1970  978307200.0L
  13.  
  14. @interface NSDate : NSObject <NSCopying, NSCoding>
  15.  
  16. - (NSTimeInterval)timeIntervalSinceReferenceDate;
  17.  
  18. @end
  19.  
  20. @interface NSDate (NSExtendedDate)
  21.  
  22. - (NSTimeInterval)timeIntervalSinceDate:(NSDate *)anotherDate;
  23. - (NSTimeInterval)timeIntervalSinceNow;
  24. - (NSTimeInterval)timeIntervalSince1970;
  25.  
  26. - (id)addTimeInterval:(NSTimeInterval)seconds;
  27.  
  28. - (NSDate *)earlierDate:(NSDate *)anotherDate;
  29. - (NSDate *)laterDate:(NSDate *)anotherDate;
  30. - (NSComparisonResult)compare:(NSDate *)other;
  31.  
  32. - (NSString *)description;
  33. - (BOOL)isEqualToDate:(NSDate *)otherDate;
  34.  
  35. + (NSTimeInterval)timeIntervalSinceReferenceDate;
  36.     
  37. @end
  38.  
  39. @interface NSDate (NSDateCreation)
  40.  
  41. + (id)date;
  42.     
  43. + (id)dateWithTimeIntervalSinceNow:(NSTimeInterval)secs;    
  44. + (id)dateWithTimeIntervalSinceReferenceDate:(NSTimeInterval)secs;
  45. + (id)dateWithTimeIntervalSince1970:(NSTimeInterval)secs;
  46.  
  47. + (id)distantFuture;
  48. + (id)distantPast;
  49.  
  50. - (id)init;
  51. - (id)initWithTimeIntervalSinceReferenceDate:(NSTimeInterval)secsToBeAdded;
  52. - (id)initWithTimeInterval:(NSTimeInterval)secsToBeAdded sinceDate:(NSDate *)anotherDate;
  53. - (id)initWithTimeIntervalSinceNow:(NSTimeInterval)secsToBeAddedToNow;
  54.  
  55. @end
  56.  
  57. /*******    Conveniences to deal with Western calendar    *******/
  58.  
  59. @interface NSDate (NSCalendarDateExtras)
  60.  
  61. #if !defined(STRICT_OPENSTEP)
  62. + (id)dateWithString:(NSString *)aString;
  63. #endif /* !STRICT_OPENSTEP */
  64.  
  65. - (id)initWithString:(NSString *)description;
  66.  
  67. - (NSCalendarDate *)dateWithCalendarFormat:(NSString *)format timeZone:(NSTimeZone *)aTimeZone;
  68.  
  69. - (NSString *)descriptionWithLocale:(NSDictionary *)locale;
  70.  
  71. - (NSString *)descriptionWithCalendarFormat:(NSString *)format timeZone:(NSTimeZone *)aTimeZone locale:(NSDictionary *)locale;
  72.  
  73. @end
  74.  
  75. #if !defined(STRICT_OPENSTEP)
  76.  
  77. @interface NSDate (NSNaturalLangage)
  78.  
  79. + dateWithNaturalLanguageString:(NSString *)string;
  80. + dateWithNaturalLanguageString:(NSString *)string locale:(NSDictionary *)dict;
  81.  
  82. @end
  83.  
  84. #endif /* !STRICT_OPENSTEP */
  85.  
  86. @interface NSTimeZone : NSObject <NSCopying, NSCoding>
  87.  
  88. + (void)setDefaultTimeZone:(NSTimeZone *)aTimeZone;
  89. + (NSTimeZoneDetail *)defaultTimeZone;
  90.  
  91. + (NSTimeZone *)localTimeZone;
  92.  
  93. + (NSDictionary *)abbreviationDictionary;
  94.  
  95. + (NSArray *)timeZoneArray;
  96.  
  97. + (NSTimeZone *)timeZoneWithName:(NSString *)aTimeZoneName;
  98. + (NSTimeZoneDetail *)timeZoneWithAbbreviation:(NSString *)abbreviation;
  99. + (NSTimeZone *)timeZoneForSecondsFromGMT:(int)seconds;
  100.  
  101. - (NSString *)timeZoneName;
  102. - (NSArray *)timeZoneDetailArray;
  103. - (NSTimeZoneDetail *)timeZoneDetailForDate:(NSDate *)date;
  104.  
  105. @end
  106.  
  107. @interface NSTimeZoneDetail : NSTimeZone
  108.  
  109. - (int)timeZoneSecondsFromGMT;
  110. - (NSString *)timeZoneAbbreviation;
  111. - (BOOL)isDaylightSavingTimeZone;
  112.  
  113. @end
  114.  
  115. @interface NSCalendarDate : NSDate {
  116.     unsigned        refCount;
  117.     NSTimeInterval     _timeIntervalSinceReferenceDate;
  118.     NSTimeZoneDetail     *_timeZone;
  119.     NSString         *_formatString;
  120.     void        *_reserved;
  121. }
  122.  
  123. + (id)dateWithYear:(int)year month:(unsigned)month day:(unsigned)day hour:(unsigned)hour minute:(unsigned)minute second:(unsigned)second timeZone:(NSTimeZone *)aTimeZone;
  124.  
  125. + (id)dateWithString:(NSString *)description calendarFormat:(NSString *)format;
  126.  
  127. + (id)dateWithString:(NSString *)description calendarFormat:(NSString *)format locale:(NSDictionary *)dict;
  128.  
  129. + (id)calendarDate;
  130.  
  131. - (id)initWithYear:(int)year month:(unsigned)month day:(unsigned)day hour:(unsigned)hour minute:(unsigned)minute second:(unsigned)second timeZone:(NSTimeZone *)aTimeZone;
  132.     
  133. - (id)initWithString:(NSString *)description;
  134. - (id)initWithString:(NSString *)description calendarFormat:(NSString *)format;
  135.  
  136. - (id)initWithString:(NSString *)description calendarFormat:(NSString *)format locale:(NSDictionary *)dict;
  137.  
  138. - (NSTimeZoneDetail *)timeZoneDetail;
  139. - (void)setTimeZone:(NSTimeZone *)aTimeZone;
  140.  
  141. - (NSString *)calendarFormat;
  142. - (void)setCalendarFormat:(NSString *)format;
  143.  
  144. - (int)yearOfCommonEra;
  145. - (int)monthOfYear;
  146. - (int)dayOfMonth;
  147. - (int)dayOfWeek;
  148. - (int)dayOfYear;
  149. - (int)dayOfCommonEra;
  150. - (int)hourOfDay;
  151. - (int)minuteOfHour;
  152. - (int)secondOfMinute;
  153.  
  154. - (NSCalendarDate *)dateByAddingYears:(int)year months:(int)month days:(int)day hours:(int)hour minutes:(int)minute seconds:(int)second;
  155.  
  156. - (void)years:(int *)yp months:(int *)mop days:(int *)dp hours:(int *)hp minutes:(int *)mip seconds:(int *)sp sinceDate:(NSCalendarDate *)date;
  157.  
  158. - (NSString *)description;
  159. - (NSString *)descriptionWithLocale:(NSDictionary *)locale;
  160. - (NSString *)descriptionWithCalendarFormat:(NSString *)format;
  161. - (NSString *)descriptionWithCalendarFormat:(NSString *)format locale:(NSDictionary *)locale;
  162.  
  163. @end
  164.  
  165.