Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-1840] Calendar range(of:, start:, interval:, for:) has incorrect type for start parameter #4564

Open
swift-ci opened this issue Jun 20, 2016 · 5 comments

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-1840
Radar None
Original Reporter Maximilian (JIRA User)
Type Bug
Environment

Xcode 8

Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug, StarterBug
Assignee None
Priority Medium

md5: 6bc90e23895979b0ef040b6445dfcae0

Issue Description:

The Calendar function

public func range(of unit: Calendar.Unit, start datep: AutoreleasingUnsafeMutablePointer<NSDate?>?, interval tip: UnsafeMutablePointer<TimeInterval>?, for date: Date) -> Bool

has a incorrect type for the start parameter. It should be Date but is instead NSDate. This is how some code looks using this function.

func numberOfDaysUntilDate() -> NSInteger {
        let units: Calendar.Unit = [.day]
        
        var fromDate: NSDate?
        var toDate: NSDate?
        var duration: TimeInterval = 0
        
        calendar.range(of: units, start: &fromDate, interval: &duration, for: Date())
        calendar.range(of: units, start: &toDate, interval: &duration, for: self)
        
        let components = calendar.components(units, from: fromDate as! Date, to: toDate as! Date, options: Calendar.Options(rawValue: 0))
        return components.day!
    }
@swift-ci
Copy link
Contributor Author

Comment by Caleb Davenport (JIRA)

I think this can be marked as resolved as these functions were marked unavailable in this commit.

@swift-ci
Copy link
Contributor Author

Comment by Magalie Allard (JIRA)

Hi Maximilian (JIRA User), I encountered the same issue today while converting CareKit to Xcode8. Try using this function instead:

https://developer.apple.com/reference/foundation/calendar/2293465-dateinterval

@swift-ci
Copy link
Contributor Author

Comment by Daniel Phillips (JIRA)

PinkYukata (JIRA User) thanks for that I was having the exact same problem and I couldn't understand where this method went in `Calendar`

@swift-ci
Copy link
Contributor Author

Comment by Caleb Davenport (JIRA)

Can this issue be closed?

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 6, 2022
@Overcot
Copy link

Overcot commented Jul 15, 2022

public func dateInterval(of component: Component, start: inout Date, interval: inout TimeInterval, for date: Date) -> Bool

I guess that this issue is no longer relevant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants