DateComponents.isValidDate() returns false if weekdayOrdinal is negative
| Originator: | ben | ||
| Number: | rdar://34441094 | Date Originated: | 9/14/17 |
| Status: | Open | Resolved: | |
| Product: | Foundation | Product Version: | |
| Classification: | Other bug | Reproducible: | Always |
Summary: When working with calendar events there is sometimes a need to specify the last Monday/Wednesday/etc. of the month. My understanding is that this is achieved by setting the DateComponents.weekdayOrdinal to -1. However, while the date components consistently resolve to the correct date, calling dateComponents.isValidDate(calendar:) returns false when weekdayOrdinal = -1. For context, I'm running into this while working with EKRecurrenceRule. Steps to Reproduce: Please see the attached playground. Expected Results: I would expect it to return true when weekdayOrdinal is negative, as long as the date exists within that month, i.e. for values between -1 and -4/-5, depending on the month. Actual Results: isValidDate(calendar:) returns false when weekdayOrdinal = -1. Version/Build: Xcode 9 GM
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!