mirror of
https://github.com/jayofelony/pwnagotchi.git
synced 2025-07-01 18:37:27 -04:00
Merge pull request #770 from gerard780/patch-1
added support for timezones with - offset
This commit is contained in:
@ -6,6 +6,7 @@ import re
|
|||||||
import datetime
|
import datetime
|
||||||
from flask import Response
|
from flask import Response
|
||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
|
from dateutil.parser import parse
|
||||||
|
|
||||||
'''
|
'''
|
||||||
2do:
|
2do:
|
||||||
@ -17,7 +18,7 @@ from functools import lru_cache
|
|||||||
https://blogs.kent.ac.uk/websolutions/2015/01/29/filtering-map-markers-with-leaflet-js-a-brief-technical-overview/
|
https://blogs.kent.ac.uk/websolutions/2015/01/29/filtering-map-markers-with-leaflet-js-a-brief-technical-overview/
|
||||||
http://www.digital-geography.com/filter-leaflet-maps-slider/
|
http://www.digital-geography.com/filter-leaflet-maps-slider/
|
||||||
http://bl.ocks.org/zross/47760925fcb1643b4225
|
http://bl.ocks.org/zross/47760925fcb1643b4225
|
||||||
-
|
-
|
||||||
'''
|
'''
|
||||||
|
|
||||||
class Webgpsmap(plugins.Plugin):
|
class Webgpsmap(plugins.Plugin):
|
||||||
@ -321,18 +322,7 @@ class PositionFile:
|
|||||||
return_ts = self._json['ts']
|
return_ts = self._json['ts']
|
||||||
elif 'Updated' in self._json:
|
elif 'Updated' in self._json:
|
||||||
# convert gps datetime to unix timestamp: "2019-10-05T23:12:40.422996+01:00"
|
# convert gps datetime to unix timestamp: "2019-10-05T23:12:40.422996+01:00"
|
||||||
date_iso_formated = self._json['Updated']
|
dateObj = parse(self._json['Updated'])
|
||||||
#fix timezone "Z": "2019-11-28T04:44:46.79231Z" >> "2019-11-28T04:44:46.79231+00:00"
|
|
||||||
if date_iso_formated.endswith("Z"):
|
|
||||||
date_iso_formated = date_iso_formated[:-1] + "+00:00"
|
|
||||||
# bad microseconds fix: fill/cut microseconds to 6 numbers
|
|
||||||
part1, part2, part3 = re.split('\.|\+', date_iso_formated)
|
|
||||||
part2 = part2.ljust(6, '0')[:6]
|
|
||||||
# timezone fix: 0200 >>> 02:00
|
|
||||||
if len(part3) == 4:
|
|
||||||
part3 = part3[1:2].rjust(2, '0') + ':' + part3[3:4].rjust(2, '0')
|
|
||||||
date_iso_formated = part1 + "." + part2 + "+" + part3
|
|
||||||
dateObj = datetime.datetime.fromisoformat(date_iso_formated)
|
|
||||||
return_ts = int("%.0f" % dateObj.timestamp())
|
return_ts = int("%.0f" % dateObj.timestamp())
|
||||||
else:
|
else:
|
||||||
# use file timestamp last modification of the json file
|
# use file timestamp last modification of the json file
|
||||||
|
@ -20,3 +20,4 @@ flask-cors==3.0.7
|
|||||||
flask-wtf==0.14.2
|
flask-wtf==0.14.2
|
||||||
dbus-python==1.2.12
|
dbus-python==1.2.12
|
||||||
toml==0.10.0
|
toml==0.10.0
|
||||||
|
python-dateutil==2.8.1
|
||||||
|
Reference in New Issue
Block a user