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-2671] Date Components return value instead of nil #4443

Open
swift-ci opened this issue Sep 16, 2016 · 1 comment
Open

[SR-2671] Date Components return value instead of nil #4443

swift-ci opened this issue Sep 16, 2016 · 1 comment

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-2671
Radar None
Original Reporter erica (JIRA User)
Type Bug

Attachment: Download

Environment

Xcode 8

Additional Detail from JIRA
Votes 1
Component/s Foundation
Labels Bug
Assignee None
Priority Medium

md5: 0cfc50f542146fceb8eeb2f9d4156906

Issue Description:

let dc = DateComponents(hour: 5, minute: 2)
print(dc.value(for: .second))

/// The calendar and timeZone and isLeapMonth property values cannot be retrieved by this method.
public func value(for component: Calendar.Component) -> Int?

Returns: Optional(9223372036854775807) instead of nil

p.s. the whole "isLeapMonth" thing for EVERY DATE COMPONENTS is really annoying

@swift-ci
Copy link
Contributor Author

swift-ci commented Apr 5, 2017

Comment by David Dunn (JIRA)

I debugged through the code and found that this issue happens for any component that you haven't explicitly given a value to. All values that should be nil seem to get replaced with the value of Int.max.

However this happens on both Mac and Linux it seems, so as far as I can tell it's expected behavior? Although it does seem somewhat strange, it would be nice to get input from Apple on this.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
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

1 participant