Skip to content

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

@swift-ci

Description

@swift-ci
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!
    }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions