Re: Getting the last date of the month?
Re: Getting the last date of the month?
- Subject: Re: Getting the last date of the month?
- From: Deborah Goldsmith <email@hidden>
- Date: Fri, 23 Mar 2007 15:21:17 -0700
I missed the original post, but I think [NSCalendar
rangeOfUnit:inUnit:forDate:] might be an easier way to do this.
Deborah Goldsmith
Internationalization, Unicode liaison
Apple Inc.
email@hidden
On Mar 20, 2007, at 11:01 AM, Jim Thomason wrote:
If you are starting with the first day of the month, as your
"firstDayOfMonth" variable name suggests, then you ought to be able
to add one month and subtract one day to get the last day of the
month.
This can be genericized even further. Apparently, NSCalendarDate
treats the "0th" of the month as the last day of the previous month.
So if you increment by 1 month and decrement by your current day of
month, it also works.
NSCalendarDate* lastOfThisMonth = [currentDate dateByAddingYears:0
months:1 days:- [currentDate dayOfMonth] hours:0 minutes:0 seconds:0];
-Jim.....
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden