The left most number is lost, causing incorrect Date value
Steps to Reproduce the Problem
async add(json: {}) {
const db = await Firestore.initialise({})
db.get().collection("path").add(json)
}
add({
date: new Date(0)
})
running the above code will generate an exception
Error processing collection add in thread
java.lang.NumberFormatException: For input string: ""
at java.lang.Long.parseLong(Long.java:606)
at java.lang.Long.parseLong(Long.java:636)
at uk.co.reallysmall.cordova.plugin.firestore.JSONDateWrapper.unwrapDate(JSONDateWrapper.java:34)
at uk.co.reallysmall.cordova.plugin.firestore.JSONHelper.fromJSON(JSONHelper.java:83)
at uk.co.reallysmall.cordova.plugin.firestore.JSONHelper.toSettableMapInternal(JSONHelper.java:119)
at uk.co.reallysmall.cordova.plugin.firestore.JSONHelper.toSettableJSONInternal(JSONHelper.java:113)
at uk.co.reallysmall.cordova.plugin.firestore.JSONHelper.fromJSON(JSONHelper.java:98)
at uk.co.reallysmall.cordova.plugin.firestore.CollectionAddHandler.handle(CollectionAddHandler.java:35)
at uk.co.reallysmall.cordova.plugin.firestore.FirestorePlugin.execute(FirestorePlugin.java:73)
...
...
The reason is because the value is encoded as __DATE:0JSONDateWrapper.unwrapDate() will strip 8 characters (prefixLength + 1), which return empty string.
Expected Behavior
Correct date value is parsed
Actual Behavior
The left most number is lost, causing incorrect Date value
Steps to Reproduce the Problem
running the above code will generate an exception
The reason is because the value is encoded as
__DATE:0
JSONDateWrapper.unwrapDate()
will strip 8 characters (prefixLength + 1
), which return empty string.The correct behaviour should be to strip 7 chars.
Specifications