qfieldsync
qfieldsync copied to clipboard
TimeZone issue during comparaison of local and cloud file
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 ?