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: "Jim Thomason" <email@hidden>
- Date: Tue, 20 Mar 2007 13:01:18 -0500
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