[SOLVED] Re: Getting the last date of the month?
[SOLVED] Re: Getting the last date of the month?
- Subject: [SOLVED] Re: Getting the last date of the month?
- From: Nick Zitzmann <email@hidden>
- Date: Tue, 20 Mar 2007 13:52:41 -0600
On Mar 20, 2007, at 11:51 AM, Greg Titus 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. Untested, written in Mail, but something like:
dateComponents = [[NSDateComponents alloc] init];
[dateComponents setMonth:1];
[dateComponents setDay:-1];
lastDayOfMonth = [calendar dateByAddingComponents:dateComponents
toDate:firstDayOfMonth options:0];
[dateComponents release];
Thanks Greg; this solution works.
Of course, it also assumes that time has no end... But I think I'm
going to stay out of that philosophical discussion. :)
Nick Zitzmann
<http://www.chronosnet.com/>
_______________________________________________
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