Name

NSCalendarDate — Mac OS X 10.0

Synopsis

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.

image with no caption

@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 ...

Get Cocoa in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.