[Django] #36626: Support sub-second resolution in GDAL Features' datetime fields

3 views
Skip to first unread message

Django

unread,
Sep 26, 2025, 3:42:12 PM (5 days ago) Sep 26
to django-...@googlegroups.com
#36626: Support sub-second resolution in GDAL Features' datetime fields
----------------------------------+---------------------------------------
Reporter: Tilman Koschnick | Type: New feature
Status: new | Component: GIS
Version: dev | Severity: Normal
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+---------------------------------------
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
--
Ticket URL: <https://code.djangoproject.com/ticket/36626>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 26, 2025, 6:05:23 PM (5 days ago) Sep 26
to django-...@googlegroups.com
#36626: Support sub-second resolution in GDAL Features' datetime fields
----------------------------------+--------------------------------------
Reporter: Tilman Koschnick | Owner: (none)
Type: New feature | Status: closed
Component: GIS | Version: dev
Severity: Normal | Resolution: wontfix
Keywords: microsecond | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------
Changes (by Jacob Walls):

* keywords: => microsecond
* resolution: => wontfix
* status: new => closed

Comment:

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 [https://github.com/django/new-
features/issues ​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
[https://docs.djangoproject.com/en/stable/internals/contributing/bugs-and-
features/#requesting-features 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 than
`tuple[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.
--
Ticket URL: <https://code.djangoproject.com/ticket/36626#comment:1>

Django

unread,
Sep 28, 2025, 4:53:17 AM (4 days ago) Sep 28
to django-...@googlegroups.com
#36626: Support sub-second resolution in GDAL Features' datetime fields
----------------------------------+--------------------------------------
Reporter: Tilman Koschnick | Owner: (none)
Type: New feature | Status: closed
Component: GIS | Version: dev
Severity: Normal | Resolution: wontfix
Keywords: microsecond | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------
Comment (by Tilman Koschnick):

Hi Jacob,

thanks for the pointers, I've created a feature request now:
[https://github.com/django/new-features/issues/82]
--
Ticket URL: <https://code.djangoproject.com/ticket/36626#comment:2>
Reply all
Reply to author
Forward
0 new messages