Skip to content

Commit

Permalink
Cleared time on request
Browse files Browse the repository at this point in the history
  • Loading branch information
christof-wittreich committed Aug 1, 2024
1 parent 364d3e9 commit 633ddd2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions web/js/map/layerbuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export default function mapLayerBuilder(config, cache, store) {

// Don't key by time if this is a static layer
if (def.period) {
date = util.toISOStringSeconds(util.roundTimeOneMinute(options.date));
date = util.toISOStringSeconds(util.roundTimeOneMinute(options.date), true);
}
if (isPaletteActive(def.id, activeGroupStr, state)) {
style = getPaletteKeys(def.id, undefined, state);
Expand Down Expand Up @@ -373,7 +373,7 @@ export default function mapLayerBuilder(config, cache, store) {
tileSize: tileSize[0],
};

const urlParameters = `?TIME=${util.toISOStringSeconds(layerDate)}`;
const urlParameters = `?TIME=${util.toISOStringSeconds(layerDate, true)}`;
const sourceURL = def.sourceOverride || configSource.url;
const sourceOptions = {
url: sourceURL + urlParameters,
Expand Down Expand Up @@ -459,7 +459,7 @@ export default function mapLayerBuilder(config, cache, store) {
if (day && def.wrapadjacentdays) {
date = util.dateAdd(date, 'day', day);
}
urlParameters = `?TIME=${util.toISOStringSeconds(util.roundTimeOneMinute(date))}`;
urlParameters = `?TIME=${util.toISOStringSeconds(util.roundTimeOneMinute(date), true)}`;

const sourceOptions = {
url: source.url + urlParameters,
Expand Down
4 changes: 3 additions & 1 deletion web/js/util/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,12 @@ export default (function(self) {
* @method toISOStringSeconds
* @static
* @param {Date} date the date to convert
* @param {Boolean} shouldRemoveTime if the time should be removed from the date
* @return {string} ISO string in the form of `YYYY-MM-DDThh:mm:ssZ`.
*/
self.toISOStringSeconds = function(date) {
self.toISOStringSeconds = function(date, shouldRemoveTime = false) {
const isString = typeof date === 'string' || date instanceof String;
if (shouldRemoveTime) date = self.clearTimeUTC(date);
const dateString = isString ? date : date.toISOString();
return `${dateString.split('.')[0]}Z`;
};
Expand Down

0 comments on commit 633ddd2

Please sign in to comment.