Hello,
A date field (callStartDate) is being converted to server local time somewhere in the ORM. We save the date as UTC ("2015-01-01T00:00:00.000Z" for this test) to the datebase, and it is stored as such in our timestamp without time zone field (2015-01-01 00:00:00). When the model object is returned by the create method, it has the correct date for this case as Wed Dec 31 2014 18:00:00 GMT-0600 (CST) in our local time. This is the same timestamp that we sent to the database.
When we do a find on the model, the date is returned as a completely different timestamp. This is shown in the gist that is posted below. The ORM always converts the dates that are sent to the database to UTC, so you would expect it to assume the dates that are stored inside are in UTC. In this case it is assuming that the data is stored in the server's local timezone of CST (Thu Jan 01 2015 00:00:00 GMT-0600 (CST)). This is a different point in time.
I know that we should be saving the timestamps as "timestamp with time zone" instead of without, but we are standardizing on UTC for storage and we would just set up a constraint to verify that only UTC data is being saved anyway.
When we DO have the column set to "timestamp with time zone", regardless of the time string sent to the database it will save the timestamp as the server's local time zone, which is also incorrect. It will save "2015-01-01T00:00:00.000Z" as "2015-01-01 00:00:00-06", which are two different points in time.
Sorry for the wall of text, but we are kind of at a loss at this point on how to proceed. Any advice on this matter would be appreciated.
Connector and model debug output here:
Version Info:
"loopback": "^2.14.0"
"loopback-boot": "^2.6.5"
"loopback-connector-postgresql": "^2.1.0"
"loopback-datasource-juggler": "^2.19.0"