Issue with timezone.
Hi, I'm having some issues with the timezone and how they are handled. I've created a small demo repo with the issue here.
Looks like the timezone, for the example it was set on "Europe/Rome", is lost when it goes to write on db.
If I do a time.Now() I'll get the right time
check timezone: 2023-09-05 14:16:21.909268 +0200 CEST m=+0.144217418
If I do the insert calling time.Now() I lose the timezone on the DB.
created first user: {
"id": "clm69yqsh00001n5t1itlcvak",
"name": "FirstUser",
"lastLogin": "2023-09-05T12:16:21.909Z"
}
doing a bit of debug, in the engine/request.go on the Do method when it do the request the payload.Query looks fine, or at least with the right time.
mutation {result: createOneUser(data:{name:"FirstUser",lastLogin:"2023-09-05T14:16:21.909309+02:00",},) {id name lastLogin }}
but then in the response the timezone was lost
{"id":"clm69yqsh00001n5t1itlcvak","name":"FirstUser","lastLogin":"2023-09-05T12:16:21.909Z"}
Am i doing something wrong? or am i missing something?
Timezones open a whole big discussion which I'm not sure I want to dig in at this time.
My suggestion would be to run your Go app using UTC timezone always, and make sure your database also runs in UTC.
You can do so by setting TZ=UTC:
TZ=UTC go run .
Let me know if you actually need to use your app in a specific timezone, and if so, why you need it, as it would help me prioritize it.
Actually, to go into more detail about your question, you are right that the timezone information gets lost, as I believe it just saves the time in UTC right now, which you might want to request as a feature.
Just to make sure, is the time itself actually correct? As the returned time would be UTC, does it still actually have the correct time, even if it's a different timezone? Or is it shifting the time by 2 hours whenever you save and find the item again?
Hi, actually it's not going to be a big deal handle the timezone in the code for now. Currently I'm using this library on side project, for track different auction markets, that's why I need timezones; and to test it and see if I can use it on some production service. Btw as I said for now it's not a big deal handle it on code-side.
About your questions, the time itself is correct, the reported "logs" are with the right timezones. The DB save it in UTC. Before adding the timezone on Go, the saved datetime was right (both in UTC).
I dunno your timeline on new features, btw tnx to resurrect this library :), I can try to look bit deeper on the issue to have more context