Class: NSDateComponents
Overview
NSDateComponents encapsulates the components of a date in an extendable, object-oriented manner. It is used to specify a date by providing the temporal components that make up a date and time: hour, minutes, seconds, day, month, year, and so on. It can also be used to specify a duration of time, for example, 5 hours and 16 minutes. An NSDateComponents object is not required to define all the component fields. When a new instance of NSDateComponents is created the date components are set to NSUndefinedDateComponent.
Instance Method Summary (collapse)
-
- calendar
Returns the calendar of the receiver.
-
- date
Returns the date of the receiver.
-
- day
Returns the number of day units for the receiver.
-
- era
Returns the number of era units for the receiver.
-
- hour
Returns the number of hour units for the receiver.
-
- isLeapMonth
Returns whether the month is a leap month.
-
- minute
Returns the number of minute units for the receiver.
-
- month
Returns the number of month units for the receiver.
-
- quarter
Returns the number of quarters in the calendar.
-
- second
Returns the number of second units for the receiver.
-
- setCalendar:
Sets the receiver’s calendar.
-
- setDay:
Sets the number of day units for the receiver.
-
- setEra:
Sets the number of era units for the receiver.
-
- setHour:
Sets the number of hour units for the receiver.
-
- setLeapMonth:
Sets the month as a leap month.
-
- setMinute:
Sets the number of minute units for the receiver.
-
- setMonth:
Sets the number of month units for the receiver.
-
- setQuarter:
Sets the number of quarters in the calendar.
-
- setSecond:
Sets the number of second units for the receiver.
-
- setTimeZone:
Sets the receiver’s time zone.
-
- setWeek:
Sets the number of week units for the receiver.
-
- setWeekday:
Sets the number of weekday units for the receiver.
-
- setWeekdayOrdinal:
Sets the ordinal number of weekday units for the receiver.
-
- setWeekOfMonth:
Sets the week of the month.
-
- setWeekOfYear:
Sets the week of the year.
-
- setYear:
Sets the number of year units for the receiver.
-
- setYearForWeekOfYear:
Sets the year for the week of the year.
-
- timeZone
Returns the receiver’s time zone.
-
- week
Returns the number of week units for the receiver.
-
- weekday
Returns the number of weekday units for the receiver.
-
- weekdayOrdinal
Returns the ordinal number of weekday units for the receiver.
-
- weekOfMonth
Returns the week of the month.
-
- weekOfYear
Returns the week of the year.
-
- year
Returns the number of year units for the receiver.
-
- yearForWeekOfYear
Returns the year for the week of the year.
Methods inherited from NSObject
#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version
Constructor Details
This class inherits a constructor from NSObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class NSObject
Instance Method Details
- (NSCalendar) calendar
Returns the calendar of the receiver. This value is interpreted in the context of the calendar with which it is used—see “Calendars, Date Components, and Calendar Units” in Date and Time Programming Guide.
- (NSDate) date
Returns the date of the receiver.
- (Integer) day
Returns the number of day units for the receiver. This value is interpreted in the context of the calendar with which it is used—see “Calendars, Date Components, and Calendar Units” in Date and Time Programming Guide.
- (Integer) era
Returns the number of era units for the receiver. This value is interpreted in the context of the calendar with which it is used—see “Calendars, Date Components, and Calendar Units” in Date and Time Programming Guide.
- (Integer) hour
Returns the number of hour units for the receiver. This value is interpreted in the context of the calendar with which it is used—see “Calendars, Date Components, and Calendar Units” in Date and Time Programming Guide.
- (Boolean) isLeapMonth
Returns whether the month is a leap month.
- (Integer) minute
Returns the number of minute units for the receiver. This value is interpreted in the context of the calendar with which it is used—see “Calendars, Date Components, and Calendar Units” in Date and Time Programming Guide.
- (Integer) month
Returns the number of month units for the receiver. This value is interpreted in the context of the calendar with which it is used—see “Calendars, Date Components, and Calendar Units” in Date and Time Programming Guide.
- (Integer) quarter
Returns the number of quarters in the calendar.
- (Integer) second
Returns the number of second units for the receiver. This value is interpreted in the context of the calendar with which it is used—see “Calendars, Date Components, and Calendar Units” in Date and Time Programming Guide.
- (Object) setCalendar(cal)
Sets the receiver’s calendar. This value is interpreted in the context of the calendar with which it is used—see “Calendars, Date Components, and Calendar Units” in Date and Time Programming Guide.
- (Object) setDay(v)
Sets the number of day units for the receiver. This value will be interpreted in the context of the calendar with which it is used—see “Calendars, Date Components, and Calendar Units” in Date and Time Programming Guide.
- (Object) setEra(v)
Sets the number of era units for the receiver. This value will be interpreted in the context of the calendar with which it is used—see “Calendars, Date Components, and Calendar Units” in Date and Time Programming Guide.
- (Object) setHour(v)
Sets the number of hour units for the receiver. This value will be interpreted in the context of the calendar with which it is used—see “Calendars, Date Components, and Calendar Units” in Date and Time Programming Guide.
- (Object) setLeapMonth(lm)
Sets the month as a leap month.
- (Object) setMinute(v)
Sets the number of minute units for the receiver. This value will be interpreted in the context of the calendar with which it is used—see “Calendars, Date Components, and Calendar Units” in Date and Time Programming Guide.
- (Object) setMonth(v)
Sets the number of month units for the receiver. This value will be interpreted in the context of the calendar with which it is used—see “Calendars, Date Components, and Calendar Units” in Date and Time Programming Guide.
- (Object) setQuarter(v)
Sets the number of quarters in the calendar. This value is interpreted in the context of the calendar with which it is used—see “Calendars, Date Components, and Calendar Units” in Date and Time Programming Guide.
- (Object) setSecond(v)
Sets the number of second units for the receiver. This value will be interpreted in the context of the calendar with which it is used—see “Calendars, Date Components, and Calendar Units” in Date and Time Programming Guide.
- (Object) setTimeZone(tz)
Sets the receiver’s time zone. This value is interpreted in the context of the calendar with which it is used—see “Calendars, Date Components, and Calendar Units” in Date and Time Programming Guide.
- (Object) setWeek(v)
Sets the number of week units for the receiver. This value will be interpreted in the context of the calendar with which it is used—see “Calendars, Date Components, and Calendar Units” in Date and Time Programming Guide.
- (Object) setWeekday(v)
Sets the number of weekday units for the receiver. Weekday units are the numbers 1 through n, where n is the number of days in the week. For example, in the Gregorian calendar, n is 7 and Sunday is represented by 1.This value will be interpreted in the context of the calendar with which it is used—see “Calendars, Date Components, and Calendar Units” in Date and Time Programming Guide.
- (Object) setWeekdayOrdinal(v)
Sets the ordinal number of weekday units for the receiver. Weekday ordinal units represent the position of the weekday within the next larger calendar unit, such as the month. For example, 2 is the weekday ordinal unit for the second Friday of the month.This value will be interpreted in the context of the calendar with which it is used—see “Calendars, Date Components, and Calendar Units” in Date and Time Programming Guide.
- (Object) setWeekOfMonth(week)
Sets the week of the month. This value is interpreted in the context of the calendar with which it is used—see “Calendars, Date Components, and Calendar Units” in Date and Time Programming Guide.
- (Object) setWeekOfYear(week)
Sets the week of the year. This value is interpreted in the context of the calendar with which it is used—see “Calendars, Date Components, and Calendar Units” in Date and Time Programming Guide.
- (Object) setYear(v)
Sets the number of year units for the receiver. This value will be interpreted in the context of the calendar with which it is used—see “Calendars, Date Components, and Calendar Units” in Date and Time Programming Guide.
- (Object) setYearForWeekOfYear(year)
Sets the year for the week of the year. This value is interpreted in the context of the calendar with which it is used—see “Calendars, Date Components, and Calendar Units” in Date and Time Programming Guide.
- (NSTimeZone) timeZone
Returns the receiver’s time zone. This value is interpreted in the context of the calendar with which it is used—see “Calendars, Date Components, and Calendar Units” in Date and Time Programming Guide.
- (Integer) week
Returns the number of week units for the receiver. This value is interpreted in the context of the calendar with which it is used—see “Calendars, Date Components, and Calendar Units” in Date and Time Programming Guide.
- (Integer) weekday
Returns the number of weekday units for the receiver. Weekday units are the numbers 1 through n, where n is the number of days in the week. For example, in the Gregorian calendar, n is 7 and Sunday is represented by 1.This value is interpreted in the context of the calendar with which it is used—see “Calendars, Date Components, and Calendar Units” in Date and Time Programming Guide.
- (Integer) weekdayOrdinal
Returns the ordinal number of weekday units for the receiver. Weekday ordinal units represent the position of the weekday within the next larger calendar unit, such as the month. For example, 2 is the weekday ordinal unit for the second Friday of the month.This value is interpreted in the context of the calendar with which it is used—see “Calendars, Date Components, and Calendar Units” in Date and Time Programming Guide.
- (Integer) weekOfMonth
Returns the week of the month. This value is interpreted in the context of the calendar with which it is used—see “Calendars, Date Components, and Calendar Units” in Date and Time Programming Guide.
- (Integer) weekOfYear
Returns the week of the year. This value is interpreted in the context of the calendar with which it is used—see “Calendars, Date Components, and Calendar Units” in Date and Time Programming Guide.