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

Known issue GCS last_modification_date without timezone when using shell client #1

Open
ice1e0 opened this issue Nov 11, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@ice1e0
Copy link
Member

ice1e0 commented Nov 11, 2020

It is a known issue that when using GCS shell client the last_modification_date method will return a datetime with maybe wrong timezone when the client and server timezone is different.

This is due to the fact that datetime.strptime does not read the timezone when %Z is used.

code ref

@ice1e0 ice1e0 added the bug Something isn't working label Nov 11, 2020
@jankatins
Copy link
Member

jankatins commented Nov 12, 2020

All the DBs/copies have a timezone parameter. Shoudl this therefore have one as well? Or do I misunderstand the problem here?

@ice1e0
Copy link
Member Author

ice1e0 commented Nov 14, 2020

My design idea was that last_modification_date should return a datetime object with tzinfo which should make sure that handling of different time zones is possible by the code calling the function.
I extended now the existing unit tests that the returned datetime must include tzinfo.

The issue here is that the gsutil tool used in the GoogleCloudStorageShellClient class returns a date time string with a text timezone. Sample: Sat, 14 Nov 2020 10:39:09 EST

I use the function datetime.strptime to parse the date time, but this method does not support reading the timezone as text. The official parameter %Z is used, but this parameter does not write the tzinfo to the datetime object.
To fix this, I added datetime.astimezone() which adds the local timezone. But the local timezone can be different as the timezone returned from the gsutil. gsutil returns the server timezone from the google cloud region as far as I can see.

We have to find another way of parsting date time with the timezone as text. This is what this issue is about. Maybe another python module must be used here since the standard module does not support this.

p.s. about the timezone parameter I suggest to remove it, see here mara/mara-db#44

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants