NSCalendarDate | Mac OS X 10.0 |
This subclass of NSDate represents dates as users would recognize them on the Western Gregorian calendar. Like NSDate, NSCalendarDate stores a date as the number of seconds since an absolute reference date. However, unlike NSDate, this class is able to return information about the date in terms of minutes, hours, days, weeks, months, and years. For example, using the method dayOfYear we can determine the day of the year a date represents (1 through 366). NSCalendarDate is also capable of providing string representations of dates using the description... methods.
In addition to storing a date value, NSCalendarDate maintains a reference to an NSTimeZone object so that dates may be accurately converted according to the user's time zone. This time zone object is accessed with the methods setTimeZone: and timeZone.
@interface NSCalendarDate : NSDate
|
// Initializers |
- (id)initWithString:(NSString *)description; |
- (id)initWithString:(NSString *)description calendarFormat:(NSString *)format; |
- (id)initWithString:(NSString *)description calendarFormat:(NSString *)format locale:(NSDictionary *)dict; |
- (id)initWithYear:(int)year month:(unsigned)month day:(unsigned)day hour:(unsigned)hour minute:(unsigned)minute second:(unsigned)second timeZone:(NSTimeZone *)aTimeZone; |
// Accessor Methods |
- (void)setTimeZone:(NSTimeZone *)aTimeZone; |
- (NSTimeZone *)timeZone;
|
- (void)setCalendarFormat:(NSString *)format; |
- (NSString *)calendarFormat;
|
// Class Methods |
+ (id)calendarDate;
|
+ (id)dateWithString:(NSString *)description calendarFormat:(NSString *)format; |
+ (id)dateWithString:(NSString *)description calendarFormat:(NSString *)format locale:(NSDictionary *)dict; |
+ (id)dateWithYear:(int)year month:(unsigned)month day:(unsigned)day hour:(unsigned)hour minute:(unsigned)minute second:(unsigned)second timeZone:(NSTimeZone *)aTimeZone; |
// Instance Methods |
- (NSCalendarDate *)dateByAddingYears:(int)year months:(int)month days:(int)day hours:(int)hour minutes:(int)minute seconds:(int)second; |
- (int)dayOfCommonEra;
|
- (int)dayOfMonth;
|
- (NSString *)description;
|
- (NSString *)descriptionWithCalendarFormat:(NSString *)format; |
- (int)dayOfWeek;
|
- (int)dayOfYear;
|
- (NSString *)descriptionWithCalendarFormat:(NSString *)format locale:(NSDictionary *)locale; |
- (NSString *)descriptionWithLocale:(NSDictionary *)locale; |
- (int)hourOfDay;
|
- (int)minuteOfHour;
|
- (int)monthOfYear;
|
- (int)secondOfMinute;
|
- (int)yearOfCommonEra;
|
- (void)years:(int *)yp months:(int *)mop days:(int *)dp hours:(int *)hp minutes:(int *)mip seconds:(int *)sp sinceDate:(NSCalendarDate *)date; |