Stackberry / Stackberry-iOS-Example

Example of how to use the Stackberry iOS SDK
0 stars 0 forks source link

Date Precision Issue #2

Open jeffreyhanna opened 7 years ago

jeffreyhanna commented 7 years ago

Overview

Dates received from Stackberry are sometimes slightly different than the date that was sent due to a precision issue.

Steps to Reproduce

  1. Set date property on object
  2. Push object to backend
  3. Sync object
  4. Compare dates

Issue

Date might be slightly modified due to a precision issue

Desired Result

I should be able to compare dates without having to add a tolerance

jeffreyhanna commented 7 years ago

This is a high priority item for us. The issue is that our current timestamp precision on the backend is up to 6 decimal places for seconds. The following example shows how that can cause comparisons to fail:

let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss.SSSSSS"
let date1 = Date()
let date1String = dateFormatter.string(from: date1)
let date2 = dateFormatter.date(from: date1String)!
print(date1.compare(date2) == .orderedSame) // prints false

We're working on a solution and will update this ticket when a fix is available in the SDK. Thank you for your patience and understanding. Please upvote this issue if it currently affects you!