iphone Programming Glossary: inunit
NSCalendar first day of week http://stackoverflow.com/questions/1106943/nscalendar-first-day-of-week stackoverflow.com a 14688780 308315 In case anyone is still paying attention to this you need to use ordinalityOfUnit inUnit forDate and set firstWeekday to 2. 1 Sunday and 7 Saturday Here's the code NSCalendar gregorian NSCalendar alloc initWithCalendarIdentifier.. 2 Sunday 1 Saturday 7 NSUInteger adjustedWeekdayOrdinal gregorian ordinalityOfUnit NSWeekdayCalendarUnit inUnit NSWeekCalendarUnit forDate NSDate date NSLog @ Adjusted weekday ordinal d adjustedWeekdayOrdinal Remember the ordinals for..
Number of days in the current month using iPhone SDK? http://stackoverflow.com/questions/1179945/number-of-days-in-the-current-month-using-iphone-sdk a date object for today's date NSCalendar c NSCalendar currentCalendar NSRange days c rangeOfUnit NSDayCalendarUnit inUnit NSMonthCalendarUnit forDate today today is an NSDate object representing the current date this can be used to work out.. with the NSDate for the current date to return the number of days in the current month using the rangeOfUnit inUnit forDate function. days.length will contain the number of days in the current month. Here are the links to the docs for NSDate..
Get all days of any month with objective-c http://stackoverflow.com/questions/1731322/get-all-days-of-any-month-with-objective-c a date object for today's date NSCalendar c NSCalendar currentCalendar NSRange days c rangeOfUnit NSDayCalendarUnit inUnit NSMonthCalendarUnit forDate today I basically want to use that but replace today with say the month of January so I can..
How do I calculate the number of days in this year in Objective C http://stackoverflow.com/questions/2078372/how-do-i-calculate-the-number-of-days-in-this-year-in-objective-c not just gregorian. I have tried this NSUInteger days NSCalendar currentCalendar rangeOfUnit NSDayCalendarUnit inUnit NSYearCalendarUnit forDate NSDate date but that gives me the number of days in the current month instead of the number of.. calendar components NSYearCalendarUnit fromDate today NSUInteger months calendar rangeOfUnit NSMonthCalendarUnit inUnit NSYearCalendarUnit forDate today .length for int i 1 i months i components.month i NSDate month calendar dateFromComponents.. i components.month i NSDate month calendar dateFromComponents components days calendar rangeOfUnit NSDayCalendarUnit inUnit NSMonthCalendarUnit forDate month .length return days It is not as neat as I would have hoped for but it will work for..
How do you calculate the day of the year for a specific date in Objective C http://stackoverflow.com/questions/2080927/how-do-you-calculate-the-day-of-the-year-for-a-specific-date-in-objective-c alloc initWithCalendarIdentifier NSGregorianCalendar NSUInteger dayOfYear gregorian ordinalityOfUnit NSDayCalendarUnit inUnit NSYearCalendarUnit forDate NSDate date gregorian release return dayOfYear where date is the date you want to determine the..
Getting human readable relative times and dates from a unix timestamp? http://stackoverflow.com/questions/4260558/getting-human-readable-relative-times-and-dates-from-a-unix-timestamp components unitFlags fromDate NSDate date NSUInteger dayOfYearForMessage calendar ordinalityOfUnit NSDayCalendarUnit inUnit NSYearCalendarUnit forDate aDate NSUInteger dayOfYearForToday calendar ordinalityOfUnit NSDayCalendarUnit inUnit NSYearCalendarUnit.. inUnit NSYearCalendarUnit forDate aDate NSUInteger dayOfYearForToday calendar ordinalityOfUnit NSDayCalendarUnit inUnit NSYearCalendarUnit forDate NSDate date NSString dateString if messageDateComponents year todayDateComponents year messageDateComponents..
|