Skip to content

Commit

Permalink
Tileserver: handle timezone-aware request parameters
Browse files Browse the repository at this point in the history
Addresses #807.
  • Loading branch information
pont-us committed Feb 10, 2023
1 parent 02632ef commit 3d7bfc6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions xcube/core/_tile2.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import PIL
import matplotlib.colors
import numpy as np
import pandas as pd
import pyproj
import xarray as xr

Expand Down Expand Up @@ -656,6 +657,12 @@ def _get_non_spatial_labels(dataset: xr.Dataset,
label = coord_var[-1].values
else:
try:
timestamp = pd.Timestamp(label)
if timestamp.tz is not None:
# Convert the timestamp to timezone-naive, since
# NumPy doesn't like parsing timezone-aware
# representations.
label = timestamp.tz_convert(None).isoformat()
label = np.array(label).astype(coord_var.dtype)
except (TypeError, ValueError) as e:
raise TileRequestException(
Expand Down

0 comments on commit 3d7bfc6

Please sign in to comment.