O'Reilly logo

Cocoa in a Nutshell by James Duncan Davidson, Michael Beam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required