-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Implementation of ISO8601DateFormatter #998
Conversation
@@ -7,6 +7,8 @@ | |||
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: We can call this file TestISO8601DateFormatter.swift
if we are okay with dropping the NS prefix from the source file name as well
@@ -10,70 +10,111 @@ | |||
import CoreFoundation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Since the class name does not have the "NS" prefix, it may make sense to drop it from the filename as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I agree, I'll remove the NS from this file and the test file as well.
Thanks for the review
#else | ||
let format = CFISO8601DateFormatOptions(self.formatOptions.rawValue) | ||
#endif | ||
let obj = CFDateFormatterCreateISO8601Formatter(kCFAllocatorSystemDefault, format)! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're doing an unchecked unwrap here, are we sure this CF function will never return a nil?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the limitations that are being placed on the values that can be passed into the CF function it shouldn't ever be able to return nil but I'm not 100% sure that is the case so I'll look into it. It may actually just be nicer if we just unwrapped the optional safely anyway rather than just using a force unwrap.
@swift-ci please test |
Seems like a test failure:
|
@alblue Thanks for that, seems the timeZone settings aren't being respected. I've added a fix that may solve the problem, would you be able to kick off the tests again? Thanks. |
@swift-ci please test |
Looks like the tests didn't run @swift-ci please test |
cc @ddunn2 |
Looks like a similar problem to before:
|
The code seems to be built around an assumption of what the current platform's timezone is:
The 'someDateTime' will automatically pick up the time zone on your machine, which is presumably UTC+1 at the moment (which is why it's assuming your Z time is 21:31). Of course this is only true iff you're in summer time in Britain, or non-summertime in Europe. If you run locally with a different TZ set, you'll see different behaviour. If you specify the date in a different way (for example, adding a Z at the end) then you may find these issues can be resolved fairly easily. Alternatively you may be able to test by switching your timezone to something else - probably by symlinking
|
@ddunn2 can you resolve the conflicting TestFoundation/main.swift file please? |
@alblue Firstly, thanks for the spot on the tests. I overlooked that the DateFormatter I was using to construct the date would also be using some default time zone as well. I took your advice and ran the tests on a VM with the time zone changed and was able to recreate the errors. I've also added a fix that should mean the tests now pass. I've fixed the merge conflicts, however Thanks again for the help! 👍 |
@swift-ci please test |
1 similar comment
@swift-ci please test |
Thanks! |
Implementation of the ISO8601DateFormatter with a suite of tests. I've been able to successfully run the tests on both mac and Linux.
I've also left the
public required init?(coder aDecoder: NSCoder)
and it's associated parts unimplemented for now.