# HG changeset patch # User Sebastien Jodogne # Date 1617364278 -7200 # Node ID dfb7429f0d484e4ebb2c3e80e72846b4791d94c6 # Parent 37de0a5ebe865358c57fa92a7f2a34812c0c8cd2# Parent 8661811abca3ad49002d7878650ce433f9a00982 integration mainline->db-changes diff -r 37de0a5ebe86 -r dfb7429f0d48 NEWS --- a/NEWS Wed Mar 31 14:35:48 2021 +0200 +++ b/NEWS Fri Apr 02 13:51:18 2021 +0200 @@ -19,6 +19,11 @@ * New functions in the SDK: - OrthancPluginCallRestApi() +Maintenance +----------- + +* Use the local timezone for query/retrieve in the Orthanc Explorer interface (was UTC before) + Version 1.9.1 (2021-02-25) ========================== diff -r 37de0a5ebe86 -r dfb7429f0d48 OrthancServer/OrthancExplorer/query-retrieve.js --- a/OrthancServer/OrthancExplorer/query-retrieve.js Wed Mar 31 14:35:48 2021 +0200 +++ b/OrthancServer/OrthancExplorer/query-retrieve.js Fri Apr 02 13:51:18 2021 +0200 @@ -31,18 +31,25 @@ **/ -function JavascriptDateToDicom(date) -{ - var s = date.toISOString(); - return s.substring(0, 4) + s.substring(5, 7) + s.substring(8, 10); -} - function GenerateDicomDate(days) { var today = new Date(); - var other = new Date(today); - other.setDate(today.getDate() + days); - return JavascriptDateToDicom(other); + var utc = new Date(today); + utc.setDate(today.getDate() + days); + + /** + * "utc" contains the date of interest, as selected by the user. + * Calling "utc.toISOString()" would return a date in the UTC + * timezone, whereas the user expects the date to be expressed in + * her own timezone. We thus adjust from UTC to the local timezome. + * https://stackoverflow.com/a/50537435 + * https://groups.google.com/g/orthanc-users/c/dK7EEPVpedk/m/DPtMRFnKAgAJ + **/ + var timezoneOffset = today.getTimezoneOffset() * 60 * 1000; + var localDate = new Date(utc.getTime() - timezoneOffset); + + var s = localDate.toISOString(); + return s.substring(0, 4) + s.substring(5, 7) + s.substring(8, 10); }