Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hack to support utc+1 datetime format #2769

Merged
merged 1 commit into from
Sep 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions geoportal/geoportailv3_geoportal/views/getfeatureinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ def format_date(self, features, attributes="date_time", format="%Y-%m-%d %H:%M:%
modified_features.append(feature)
return modified_features

def format_esridate(self, features, attributes="date_time", format="%Y-%m-%d %H:%M:%S"):
def format_esridate(self, features, attributes="date_time", format="%Y-%m-%d %H:%M:%S", use_local_time=False, delta_hours=0):
modified_features = []
if type(attributes) != type([]):
attributes = [attributes]
Expand All @@ -814,10 +814,20 @@ def format_esridate(self, features, attributes="date_time", format="%Y-%m-%d %H:
value = feature['attributes'][attribute]
if value is not None:
utc_dt = datetime.datetime.fromtimestamp(int(value)/1000.0, tz=pytz.utc)
lux_tz = pytz.timezone("Europe/Luxembourg")
local_time = lux_tz.normalize(utc_dt)
feature['attributes'][attribute] =\
local_time.strftime(format)
if use_local_time:
hours_added = datetime. timedelta(hours = delta_hours)
dt = utc_dt + hours_added
lux_tz = pytz.timezone("Europe/Luxembourg")
local_time = lux_tz.normalize(utc_dt)
feature['attributes'][attribute] =\
local_time.strftime(format)
else:
utc_dt = datetime.datetime.fromtimestamp(int(value)/1000.0)
hours_added = datetime. timedelta(hours = delta_hours)
dt = utc_dt + hours_added
feature['attributes'][attribute] =\
dt.strftime(format)

except Exception as e:
log.exception(e)
modified_features.append(feature)
Expand Down