@@ -195,7 +195,7 @@ REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': (
'layerindex.restperm.ReadOnlyPermission',
),
- 'DATETIME_FORMAT': '%Y-%m-%dT%H:%m:%S+0000',
+ 'DATETIME_FORMAT': '%Y-%m-%dT%H:%M:%S+0000',
}
# A sample logging configuration. The only tangible logging
@@ -195,7 +195,7 @@ REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': (
'layerindex.restperm.ReadOnlyPermission',
),
- 'DATETIME_FORMAT': '%Y-%m-%dT%H:%m:%S+0000',
+ 'DATETIME_FORMAT': '%Y-%m-%dT%H:%M:%S+0000',
}
# A sample logging configuration. The only tangible logging
new file mode 100644
@@ -0,0 +1,30 @@
+# layerindex-web - tests for the REST API
+#
+# Licensed under the MIT license, see COPYING.MIT for details
+#
+# SPDX-License-Identifier: MIT
+
+import datetime
+
+import pytest
+from django.test import TestCase
+
+from layerindex.models import LayerItem
+
+
+@pytest.mark.django_db
+class TestRestApiDatetimes(TestCase):
+
+ def test_datetime_format(self):
+ layer = LayerItem.objects.create(name='meta-test', status='P', layer_type='A',
+ summary='test', description='test',
+ vcs_url='git://example.com/meta-test.git')
+ # auto_now would overwrite a value passed to save()
+ LayerItem.objects.filter(pk=layer.pk).update(updated=datetime.datetime(2026, 10, 18, 14, 37, 5))
+
+ response = self.client.get('/layerindex/api/layerItems/', {'format': 'json'})
+ self.assertEqual(response.status_code, 200)
+ data = response.json()
+ items = data['results'] if isinstance(data, dict) else data
+ item = next(i for i in items if i['name'] == 'meta-test')
+ self.assertEqual(item['updated'], '2026-10-18T14:37:05+0000')
REST_FRAMEWORK['DATETIME_FORMAT'] used %m (the month) where the minutes belong, so every timestamp the API returned had the month in place of the minutes: 14:37 in October came out as 14:10. Use %M. bitbake's layerindexlib keeps these values as opaque strings, so it is not affected. AI-Generated: Claude Opus 5.5 Signed-off-by: Tim Orling <tim.orling@konsulko.com> --- docker/settings.py | 2 +- settings.py | 2 +- tests/test_restapi.py | 30 ++++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 tests/test_restapi.py base-commit: e6040597ae0f614581de241fe78f20e34dae13ac