A Foundation for WebScript Programmers: Quick Guide to Useful Classes
Table of Contents Previous Section
Commonly Used NSCalendarDate Methods
The following sections list some of the most commonly used methods of NSCalendarDate. The methods covered are grouped in the following categories:
Creating NSCalendarDates
The methods in this section are class methods, as denoted by the plus sign (+). You use class methods to send messages to a class-in this case, NSCalendarDate. For more information on class methods, see "Messaging in WebScript" in "Using WebScript."
- + calendarDate
- Returns an NSCalendarDate initialized to the current date and time.
- + dateWithString:calendarFormat:
- Returns an NSCalendarDate initialized to the date in a provided string, and sets the new NSCalendarDate's calendar format to the specified format. The date string must match the provided format exactly. See "The Calendar Format" for more detailed information on formats used by NSCalendarDate.
Adjusting an NSCalendarDate
- - dateByAddingYears:months:days:hours:minutes:seconds:
- Returns an NSCalendarDate derived from the receiver by adding a specified number of years, months, days, hours, minutes, and seconds.
Representing NSCalendarDates as Strings
- - description
- Returns a string representation of the NSCalendarDate formatted according to the NSCalendarDate's default calendar format.
- - descriptionWithCalendarFormat:
- Returns a string representation of the receiver formatted according to the provided format string.
- - calendarFormat
- Returns a string that indicates the receiver's default calendar format. See "The Calendar Format" for more detailed information on formats used by NSCalendarDate.
- - setCalendarFormat:
- Set the receiver's default calendar format to the provided string.
Retrieving NSCalendarDate Elements
- - dayOfWeek
- Returns a number that indicates the NSCalendarDate's day of the week (0-6).
- - dayOfMonth
- Returns the NSCalendarDate's day of the month (1-31).
- - dayOfYear
- Returns a number that indicates the NSCalendarDate's day of the year (1-366).
- - dayOfCommonEra
- Returns the NSCalendarDate's number of days since the beginning of the Common Era. The base year of the Common Era is 1 A.C.E. (which is the same as 1 A.D.).
- - monthOfYear
- Returns a number that indicates the NSCalendarDate's month of the year (1-12).
- - yearOfCommonEra
- Returns the NSCalendarDate's year value (including the century).
- - hourOfDay
- Returns the NSCalendarDate's hour value (0-23).
- - minuteOfHour
- Returns the NSCalendarDate's minutes value (0-59).
- - secondOfMinute
- Returns the NSCalendarDate's seconds value (0-59).