add date time component

Send Snippet To: Save this snippet to Code Collector Pro -- view all balzan's snippets
language: Objective-C
license: Other

Code for Snippet:

	NSDate* endDate = nil;
	NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
	NSDateComponents *offsetComponents = [[NSDateComponents alloc] init];
	if(self.timeType == Hourly || self.timeType == Daily) {
			[offsetComponents setDay:1];
	} else if (self.timeType == Weekly) {
			[offsetComponents setWeek:1];
	} else if (self.timeType == Monthly) {
		[offsetComponents setMonth:1];
	} else if (self.timeType == Yearly) {
		[offsetComponents setYear:1];
	endDate = [gregorian dateByAddingComponents:offsetComponents toDate:firstDate options:0];
comments powered by Disqus


Link to this snippet:

Download to Code Collector

To use the direct link to your snippet on either copy the html from the above section or drag the Download to Code Collector to where you would like to use it.

More Info:

Times Viewed: 359
Date Added: 2012-08-28 04:32:17
Last Modified: 2014-02-18 20:29:31

Web Analytics