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
fix parsing of dates in receipts with milliseconds #367
Conversation
guard let dateBytes = "2020-07-14T19:36:40+0000".data(using: .ascii) else { fatalError() } | ||
guard let dateBytes = "2020-07-14T19:36:40Z".data(using: .ascii) else { fatalError() } |
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.
this isn't really necessary, and the code will work in either format, but it resembles the actual strings in receipts a little more closely
looks like circleCI is having issues. Tests pass locally, though. |
let date = Calendar.current.date(from: dateComponents) | ||
guard let dateBytes = "2020-07-14T19:36:40.202Z".data(using: .ascii) else { fatalError() } | ||
let receivedDate = ISO3601DateFormatter.shared.date(fromBytes: ArraySlice(dateBytes)) | ||
expect(receivedDate!.timeIntervalSince1970).to(beCloseTo(date!.timeIntervalSince1970)) |
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.
We can't compare same way we do in the other test because of the precision issue you mentioned to me in private?
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, floating point precision is a killer here.
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.
really, we should be doing this on any and all floating point comparisons. I can update the other one.
* fixed parsing of apple receipts when dates have millisecond resolution * escaped the dot so that it works correctly with international formats * learned to spell milliseconds
It looks like Apple might have changed the format of dates in receipts, updating the resolution from seconds to milliseconds.
This PR updates our parser so that we handle both cases, since some receipts will still be in the old format even after the update.
More info: https://twitter.com/depth42/status/1313750495710904320