triniwiz / triniwiz/nativescript-plugins
[couchbase] iOS date problems
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 87
- Forks
- 57
- Avg merge
- 1h 36m
- Merged PRs (30d)
- 4
Description
I'm experiencing some strange problems with dates being saved/loaded in the DB as null values. It is very random. So far it is happening for different locales, different time zones. Sometimes in a single object that has 2 fields with dates - one might get it right and the other one get as null. I'm not able to determine any pattern.
Looking at the code seems you are using NSDateFormatter to serialize dates using their JS .toISOString(). Reading through some best practices, seems when you want a fixed format it is best you also set the local to en_US_POSIX to avoid problems:
https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/DataFormatting/Articles/dfDateFormatting10_4.html#//apple_ref/doc/uid/TP40002369-SW7
Also for iOS10+ it is recommended to use the newly introduced NSISO8601DateFormatter
https://developer.apple.com/documentation/foundation/nsdateformatter#2528261
https://developer.apple.com/documentation/foundation/nsiso8601dateformatter
What do you think to tweak the logic and use either ot those?
Also is there any reason why you have made the format use the Z timezone pattern, instead of the char Z. So you have
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
instead of
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
Here is an example of how the string format looks like with either of those: https://swiftfiddle.com/?c=H4sIAAAAAAAAA6tWSlayUsrMLcgvKlFwyy%2FNS0ksyczPiwHCnNQShQoFWwWXxJJUt%2Fyi3MSSktQiDU2QVIVeClwQqCJGqRIIdH19dVNS1EPUPTyscnOtiov1goODo2KUYvIKijLzSjQq9IpLgIx0jbSi%2FFwrsLF6efnlmiSaqB6lToSZSjpKZUCPmekZ6Bkp1QIAEfFcXeYAAAA%3D
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the iOS date serialization and deserialization logic that uses NSDateFormatter, focusing on locale, time-zone, and ISO 8601 handling. Reproduce the null-date behavior across the reported locales and time zones; done means dates consistently round-trip instead of becoming null.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ios, typescript
- Domain
- database, mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100