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

DATETIME: Wrong timezone for UTC in attribute table #48393

Closed
2 tasks done
pathmapper opened this issue Apr 29, 2022 · 6 comments
Closed
2 tasks done

DATETIME: Wrong timezone for UTC in attribute table #48393

pathmapper opened this issue Apr 29, 2022 · 6 comments
Labels
Attribute Table Bug Either a bug report, or a bug fix. Let's hope for the latter!

Comments

@pathmapper
Copy link
Contributor

pathmapper commented Apr 29, 2022

What is the bug or the crash?

Z for Zero timezone (UTC) is ignored, instead local timezone is displayed in attribute table.

Tested for GPKG (type DATETIME) and GeoJSON files and also for a WFS layer:

"timestamp": "2022-04-13T12:05:23Z"

results e.g. in

grafik

So in this example the displayed time is wrong by 2 hours.

Steps to reproduce the issue

  1. Extract and inspect test data (GPKG and GeoJSON): test_data.zip
  2. Drag'n'drop files into QGIS
  3. Open attribute table
  4. See error: local timezone is displayed but there shoud be zero timezone (UTC)

Versions

master (cca3562) on Ubuntu

and

3.24.2 on Windows

QGIS-Version 3.24.2-Tisler QGIS-Codeversion 13c1a02
Qt-Version 5.15.2
Python-Version 3.9.5
GDAL-Version 3.4.2
PROJ-Version 9.0.0
EPSG-Registraturdatenbankversion v10.054 (2022-02-13)
GEOS-Version 3.10.2-CAPI-1.16.0
SQLite-Version 3.38.1
PDAL-Version 2.3.0
PostgreSQL-Client-Version unknown
SpatiaLite-Version 5.0.1
QWT-Version 6.1.3
QScintilla2-Version 2.11.5
BS-Version Windows 10 Version 1809
       
Aktive Python-Erweiterungen
db_manager 0.1.20
grassprovider 2.12.99
MetaSearch 0.3.6
processing 2.12.99
sagaprovider 2.12.99

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

  • I tried with a new QGIS profile

Additional context

If the layer is exported, e.g. to GeoJSON, the Z from the timestamp is missing:

Before import::
2022-04-13T12:05:23Z

After export:
2022-04-13T12:05:23


Related SE post:

@pathmapper pathmapper added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Apr 29, 2022
@pathmapper pathmapper changed the title DATETIME (WFS/GPKG/GeoJSON): Z for Zero timezone (UTC) is ignored, instead local timezone is displayed in attribute table DATETIME: Wrong timezone for UTC is displayed in attribute table May 5, 2022
@pathmapper pathmapper changed the title DATETIME: Wrong timezone for UTC is displayed in attribute table DATETIME: Wrong timezone for UTC in attribute table May 5, 2022
@pathmapper
Copy link
Contributor Author

Looks like the timezone shown for DateTime fields in the attribute table and the identify features tool is currently the OS timezone and has nothing to do with the data timezone.

E.g. for Windows, if you set the OS timzone in the Windows seetings to UTC-10 - Hawaii

grafik

for the test data provided above the timezone shown in the attribute table and identify feature result is also Hawaii:

grafik

grafik

@heidivanparys
Copy link
Contributor

This is really a problem for GeoPackage, as GeoPackage files must have the timestamps as UTC time according to the GeoPackage standard, see also opengeospatial/geopackage#530, especially this comment: opengeospatial/geopackage#530 (comment):

[…] the OAB recommends that standards conform to the UTC time as specified in both OWS Common and the existing GeoPackage text […]

So currently I have the option between

  • creating GeoPackage files where timestamps have a UTC offset, which are shown correctly in QGIS but are not in accordance with the spec;
  • or creating GeoPackage files where timestamps are in Zulu time, in accordance with the spec, but that are shown incorrectly in QGIS.

@pathmapper
Copy link
Contributor Author

creating GeoPackage files where timestamps have a UTC offset, which are shown correctly in QGIS but are not in accordance with the spec

Additionally this would work currently only if the UTC-offset matches the OS timzone - so it would be specific for the machine/settings you are using. For different settings and/or machine with different OS timezone, the offset would not match what is displayed in QGIS.

@heidivanparys
Copy link
Contributor

For reference, related discussions on the QGIS developer mailinglist:

rouault added a commit that referenced this issue Mar 21, 2023
[queued_ltr_backports] [OGR] Round-trip milliseconds and timezone in DateTime fields (fixes #48393, fixes #44160)
@drf5n
Copy link

drf5n commented Apr 26, 2024

Steps to reproduce the issue

  1. Extract and inspect test data (GPKG and GeoJSON): test_data.zip
  2. Drag'n'drop files into QGIS
  3. Open attribute table
  4. See error: local timezone is displayed but there shoud be zero timezone (UTC)

The test data in the github.com/qgis/QGIS/issues/48393 -- github.com/qgis/QGIS/files/8592150/test_data.zip -- has internal timestamps of 2022-04-13T12:05:23.000Z If those aren't treated as UTC time within QGIS, QGIS is wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Attribute Table Bug Either a bug report, or a bug fix. Let's hope for the latter!
Projects
None yet
Development

No branches or pull requests

4 participants