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-208] Setting .dateFormat of NSDateFormatter has no effect #4375

Closed
swift-ci opened this issue Dec 12, 2015 · 3 comments
Closed

[SR-208] Setting .dateFormat of NSDateFormatter has no effect #4375

swift-ci opened this issue Dec 12, 2015 · 3 comments

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-208
Radar None
Original Reporter joeiachievedit (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

Ubuntu 14.04 with
Swift version 2.2-dev (LLVM 46be9ff861, Clang 4deb154edc, Swift 778f829)
Target: x86_64-unknown-linux-gnu

Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug
Assignee tfrank64 (JIRA)
Priority Medium

md5: a496382187495b94fd7961062de2d604

Issue Description:

The following code:

import Foundation

let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = String("dd-MM-yyyy")
var dateStr = dateFormatter.stringFromDate(NSDate())

print("With dateFormat '\(dateFormatter.dateFormat)':  '\(dateStr)'")

dateFormatter.dateStyle = .MediumStyle
dateFormatter.timeStyle = .MediumStyle
dateStr = dateFormatter.stringFromDate(NSDate())
print("With dateStyle and timeStyle set to .MediumStyle:  '\(dateStr)'")

should result in

With dateFormat 'dd-MM-yyyy':  '12-12-2015'
With dateStyle and timeStyle set to .MediumStyle:  'Dec 12, 2015, 9:46:33 PM'

Instead it results in:

With dateFormat 'dd-MM-yyyy':  ''
With dateStyle and timeStyle set to .MediumStyle:  'Dec 12, 2015, 9:46:33 PM'

It appears that setting the dateFormat property of a NSDateFormatter instance has no effect.

@swift-ci
Copy link
Contributor Author

Comment by Joe (JIRA)

Note: The swift compiler used was compiled with the latest sources on Github, but this issue is reproducible with both SNAPSHOT releases from Apple.

@swift-ci
Copy link
Contributor Author

Comment by Taylor Franklin (JIRA)

assigning myself per discussion here https://lists.swift.org/pipermail/swift-corelibs-dev/Week-of-Mon-20160215/subject.html

@swift-ci
Copy link
Contributor Author

Comment by Taylor Franklin (JIRA)

Resolved with this pull request: #288
See TestNSDateFormatter.swift for working example.

@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
This issue was closed.
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