-
-
Notifications
You must be signed in to change notification settings - Fork 33
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
Send UTC TZ for mod creation timestamps #265
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this is just a workaround. If we want to fix the problem, you should change
SpaceDock/KerbalStuff/objects.py
Line 230 in 0e5f6c5
self.created = datetime.now() |
to datetime.utcnow()
to return the UTC date.
Obviously it would apply to newly created mods only, so it would need your change as well to convert the current mods to UTC.
@RockyTV are you sure that would save to the db? I saw reports that PostgreSQL doesn't save the TZ. |
Looks like Postgres would support timezones: I think we could use it by changing this line to SpaceDock/KerbalStuff/objects.py Line 349 in 0e5f6c5
https://docs.sqlalchemy.org/en/13/core/type_basics.html#sqlalchemy.types.DateTime This section also says the following, not sure what it means exactly:
|
@DasSkelett I think that's another branch, that line looks a bit different on alpha: SpaceDock/KerbalStuff/objects.py Line 305 in 67262ca
... which goes back to the discussion about having to use a lambda. And I don't want to get into that with fourteen other instances of this for other fields in that ifle. |
Okay I see. Then let's stay with saving the local time (which fortunately is UTC), and converting it when handing it out via API, as your PR does currently. If we want to, we can clean this up later, all instances of this at once, with a data migration and so on. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's try it. Not 100% sure if netkan will convert +00:00
to Z
to match mods from other APIs, but I think so.
We should give it a try.
Problem
As noted in Discord during review of KSP-CKAN/CKAN#3059, the timestamps from #195 don't indicate timezones. Technically this means they're in "local" time, whatever that means for a server/client interaction.
Cause
We just return
created
from the database, which is generated bydatetime.now
, which does not include the timezone:SpaceDock/KerbalStuff/objects.py
Line 230 in 0e5f6c5
It's not clear whether the timezone can be saved to the db anyway, though. At least one comment on StackExchange suggested it couldn't. So we can add it at load instead.
Changes
Now we set the TZ to UTC.