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 18:11:37 -0700
Well, it's not working the way I expected. :-)
The documentation says this:
You can use this method to calculate, for example, the range the
Day unit can take on in the Month in which date lies.
It's supposed to return the *range*, not the quantity. Either the
documentation is wrong, or the implementation is wrong.
Admittedly this is an odd case, since the range is discontiguous.
However, the documentation implies that you're getting the minimum
and maximum value. Since that month starts with the value 1, and ends
with the value 31, the range of values is from 1 to 31. It doesn't
matter that 10 of them are missing. I'm pretty sure that this is what
the API is intended to do, especially having looked at the
implementation. ;-) You can get the number of days in the month by
other means, like [NSCalendar components:fromDate:toDate:options:].
If you still don't want to write a bug, please let me know and I
will. :-)
Deborah Goldsmith
Internationalization, Unicode liaison
Apple Inc.
email@hidden
On Mar 23, 2007, at 5:13 PM, Nick Zitzmann wrote:
On Mar 23, 2007, at 5:57 PM, Deborah Goldsmith wrote:
That sounds like a bug to me. I would suggest filing it in Radar.
Actually, it's working as expected. -rangeOfUnit:inUnit:forDate:
returns a unit in a unit, and if you try using it to get the number
of days in the month of October 1582, it returns the correct value
(21 days, because Pope Gregory deleted 10 days from the calendar
that month). But the last date in October 1582 is the 31st, not the
21st, so -rangeOfUnit:inUnit:forDate: is working as expected, but
it only works for getting the last date of the month if we can
assume the last day in the month is equal to the number of days in
the month. In this case, we can't, so I had to find another method.
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