From 487381a925e65462a41be773cb69dbc227b99b8a Mon Sep 17 00:00:00 2001 From: Franz-Benjamin Mocnik Date: Sun, 15 Aug 2021 23:03:36 +0200 Subject: [PATCH] element, overpass: return timestamps as objects --- OSMPythonTools/element.py | 3 ++- OSMPythonTools/overpass.py | 5 +++-- docs/element.md | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/OSMPythonTools/element.py b/OSMPythonTools/element.py index 45f505f..b06c2c5 100644 --- a/OSMPythonTools/element.py +++ b/OSMPythonTools/element.py @@ -1,4 +1,5 @@ import copy +import dateutil.parser import geojson import re @@ -71,7 +72,7 @@ def version(self): def changeset(self): return self.__getElement('changeset') def timestamp(self): - return self.__getElement('timestamp') + return dateutil.parser.isoparse(self.__getElement('timestamp')) def user(self): return self.__getElement('user') def uid(self): diff --git a/OSMPythonTools/overpass.py b/OSMPythonTools/overpass.py index 5fd67df..3fb2ed1 100755 --- a/OSMPythonTools/overpass.py +++ b/OSMPythonTools/overpass.py @@ -1,6 +1,7 @@ from OSMPythonTools.nominatim import Nominatim, NominatimResult import datetime as dt import sys +import dateutil.parser import time import urllib.parse import urllib.request @@ -132,9 +133,9 @@ def version(self): def generator(self): return self.__get('generator') def timestamp_osm_base(self): - return self.__get2('osm3s', 'timestamp_osm_base') + return dateutil.parser.isoparse(self.__get2('osm3s', 'timestamp_osm_base')) def timestamp_area_base(self): - return self.__get2('osm3s', 'timestamp_area_base') + return dateutil.parser.isoparse(self.__get2('osm3s', 'timestamp_area_base')) def copyright(self): return self.__get2('osm3s', 'copyright') def remark(self): diff --git a/docs/element.md b/docs/element.md index 4c72fff..99b87ff 100644 --- a/docs/element.md +++ b/docs/element.md @@ -125,5 +125,5 @@ changedNodes.elements()[0].user() changedNodes.elements()[0].userid() # 4913117 changedNodes.elements()[0].timestamp() -'2017-01-03T13:47:23Z' +# 2017-01-03 13:47:23+00:00' ```