#36626 closed New feature (wontfix)
Support sub-second resolution in GDAL Features' datetime fields
Reported by: | Tilman Koschnick | Owned by: | |
---|---|---|---|
Component: | GIS | Version: | dev |
Severity: | Normal | Keywords: | microsecond |
Cc: | Tilman Koschnick | Triage Stage: | Unreviewed |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Hi,
I have a GPX DataSource with points that have sub-second resolution:
<trkpt lat="47.454540000" lon="8.573658000"> <ele>436.900</ele> <time>2025-09-25T12:24:42.990Z</time> </trkpt>
The GDAL API returns these only with second resolution, although the underlying datetime presentation is still accessible with the as_string() method:
>>> point <django.contrib.gis.gdal.feature.Feature object at 0x7f99254b9190> >>> point.get('time') datetime.datetime(2025, 9, 25, 12, 24, 42) >>> point['time'] <django.contrib.gis.gdal.field.OFTDateTime object at 0x7f99253212b0> >>> point['time'].as_datetime() (c_int(2025), c_int(9), c_int(25), c_int(12), c_int(24), c_int(42), c_int(100)) >>> point['time'].as_string() '2025/09/25 12:24:42.990+00'
In my case, I lose information, and end up being at different locations at the same time ;)
Would it be possible to support sub-second resolutions in the GDAL API? As I understand it, OGR_F_GetFieldAsDateTime() is used to return the datetime object:
https://gdal.org/en/stable/doxygen/ogr__api_8h.html#a47ca681bb6099eb8c18004d1f7112d95
GDAL also provides OGR_F_GetFieldAsDateTimeEx() that returns seconds as float with millisecond accuracy:
https://gdal.org/en/stable/doxygen/ogr__api_8h.html#a748995fa28574b25f6b723013a405a8f
I unfortunately don't understand the GDAL API enough to provide a patch myself.
Regards, Til
Change History (2)
comment:1 by , 3 weeks ago
Keywords: | microsecond added |
---|---|
Resolution: | → wontfix |
Status: | new → closed |
comment:2 by , 3 weeks ago
Hi Jacob,
thanks for the pointers, I've created a feature request now: https://github.com/django/new-features/issues/82
Hi Til,
Thanks for this suggestion. When suggesting a new feature for Django, the feature idea should first be proposed and discussed with the community. To do that, please raise this on the new feature tracker.
I'll close the ticket for now, but if the community agrees with the proposal, please return to this ticket and reference the forum discussion so we can re-open it. For more information, please refer to the documented guidelines for requesting features.
There's probably a backwards compatibility piece here also, as it sounds like the proposal is to make
as_datetime()
return something other thantuple[int, int, int, int, int, int]
(where the penultimate int is the second). So if you can put some thought to that when writing your new features issue, that would be appreciated.