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

TimeZone issue during comparaison of local and cloud file #606

Open
qsavoye opened this issue Aug 19, 2024 · 0 comments
Open

TimeZone issue during comparaison of local and cloud file #606

qsavoye opened this issue Aug 19, 2024 · 0 comments

Comments

@qsavoye
Copy link

qsavoye commented Aug 19, 2024

QGIS (please complete the following information)

  • OS: Windows 11
  • QGIS Version 3.38.1
  • QFieldSync Version 4.10.1
  • QfieldCloud 0.28

Describe the issue

I self host a QfieldCloud instance in a server in Germany. I set my environement variable to 'Europe/Berlin' UTC+2 on my env file.
I have a modification of a cloud file at 11h30 UTC that is correct according to my action and my local file last update is 11h00 UTC

When i would like to synchronise on qgis, it says that my local file is the last updated file instead of the cloud file.

I put some log message on add_file_checkbox_buttons function.

project_file.updated_at is correct with UTC timezone but

                cloud_updated_at = datetime.strptime(
                    project_file.updated_at, "%d.%m.%Y %H:%M:%S %Z"
                ).timestamp()

Give me a timestamp with 2 hours less

To correct it, I have to specify that datetime timezone is UTC

cloud_updated_date = datetime.strptime(
       project_file.updated_at, "%d.%m.%Y %H:%M:%S %Z"
)
# Create a timezone object for UTC
utc_tz = pytz.timezone('UTC')
# Add the timezone information to the datetime object
cloud_updated_date = utc_tz.localize(cloud_updated_date)
cloud_updated_at = cloud_updated_date.timestamp()

I think that %Z is not taking into account with datetime.strptime in my case. Do you have any idea why ?

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

No branches or pull requests

1 participant