Skip to content

Commit 0458416

Browse files
authored
Merge pull request #7 from sentinel-hub/fix/legacy-compat-utc-dates
2 small issues with legacyCompat
2 parents 15e02d3 + 01484ac commit 0458416

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/legacyCompat.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,9 @@ function bboxFromParams(service: ServiceType, version: string, crsAuthId: CRS_ID
304304
default:
305305
throw new Error('Unsupported CRS - bbox could not be parsed');
306306
}
307+
// SH services support switched min & max X/Y, but we don't:
308+
[minX, maxX] = [Math.min(minX, maxX), Math.max(minX, maxX)];
309+
[minY, maxY] = [Math.min(minY, maxY), Math.max(minY, maxY)];
307310
return new BBox(crs, minX, minY, maxX, maxY);
308311
}
309312

@@ -337,15 +340,15 @@ function timeFromParams(params: any): Date[] {
337340
fromTime = new Date(timeParts[0]);
338341
toTime = new Date(timeParts[1]);
339342
if (!isTimeSpecifiedInDate(timeParts[1])) {
340-
toTime.setHours(23, 59, 59, 999);
343+
toTime.setUTCHours(23, 59, 59, 999);
341344
}
342345
} else if (timeParts.length === 1) {
343346
// "When a single time is specified the service will return data from beginning of
344347
// satellite mission until the specified time"
345348
fromTime = new Date('1970-01-01');
346349
toTime = new Date(timeParts[0]);
347350
if (!isTimeSpecifiedInDate(timeParts[0])) {
348-
toTime.setHours(23, 59, 59, 999);
351+
toTime.setUTCHours(23, 59, 59, 999);
349352
}
350353
}
351354

0 commit comments

Comments
 (0)