Skip to content

Commit

Permalink
Merge pull request #7 from sentinel-hub/fix/legacy-compat-utc-dates
Browse files Browse the repository at this point in the history
2 small issues with legacyCompat
  • Loading branch information
dgostencnik authored Jan 29, 2020
2 parents 15e02d3 + 01484ac commit 0458416
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/legacyCompat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@ function bboxFromParams(service: ServiceType, version: string, crsAuthId: CRS_ID
default:
throw new Error('Unsupported CRS - bbox could not be parsed');
}
// SH services support switched min & max X/Y, but we don't:
[minX, maxX] = [Math.min(minX, maxX), Math.max(minX, maxX)];
[minY, maxY] = [Math.min(minY, maxY), Math.max(minY, maxY)];
return new BBox(crs, minX, minY, maxX, maxY);
}

Expand Down Expand Up @@ -337,15 +340,15 @@ function timeFromParams(params: any): Date[] {
fromTime = new Date(timeParts[0]);
toTime = new Date(timeParts[1]);
if (!isTimeSpecifiedInDate(timeParts[1])) {
toTime.setHours(23, 59, 59, 999);
toTime.setUTCHours(23, 59, 59, 999);
}
} else if (timeParts.length === 1) {
// "When a single time is specified the service will return data from beginning of
// satellite mission until the specified time"
fromTime = new Date('1970-01-01');
toTime = new Date(timeParts[0]);
if (!isTimeSpecifiedInDate(timeParts[0])) {
toTime.setHours(23, 59, 59, 999);
toTime.setUTCHours(23, 59, 59, 999);
}
}

Expand Down

0 comments on commit 0458416

Please sign in to comment.