Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with timezone. #979

Open
claudioquaglia opened this issue Sep 5, 2023 · 3 comments
Open

Issue with timezone. #979

claudioquaglia opened this issue Sep 5, 2023 · 3 comments

Comments

@claudioquaglia
Copy link

claudioquaglia commented Sep 5, 2023

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?

@steebchen
Copy link
Owner

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.

@steebchen
Copy link
Owner

steebchen commented Sep 5, 2023

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?

@claudioquaglia
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

2 participants