comparison OrthancServer/OrthancExplorer/query-retrieve.js @ 4610:8661811abca3

Use the local timezone for query/retrieve in the Orthanc Explorer interface (was UTC before)
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 02 Apr 2021 13:50:56 +0200
parents d9473bd5ed43
children f0038043fb97 72a850947b11
comparison
equal deleted inserted replaced
4605:c8f444e8556d 4610:8661811abca3
29 * You should have received a copy of the GNU General Public License 29 * You should have received a copy of the GNU General Public License
30 * along with this program. If not, see <http://www.gnu.org/licenses/>. 30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
31 **/ 31 **/
32 32
33 33
34 function JavascriptDateToDicom(date)
35 {
36 var s = date.toISOString();
37 return s.substring(0, 4) + s.substring(5, 7) + s.substring(8, 10);
38 }
39
40 function GenerateDicomDate(days) 34 function GenerateDicomDate(days)
41 { 35 {
42 var today = new Date(); 36 var today = new Date();
43 var other = new Date(today); 37 var utc = new Date(today);
44 other.setDate(today.getDate() + days); 38 utc.setDate(today.getDate() + days);
45 return JavascriptDateToDicom(other); 39
40 /**
41 * "utc" contains the date of interest, as selected by the user.
42 * Calling "utc.toISOString()" would return a date in the UTC
43 * timezone, whereas the user expects the date to be expressed in
44 * her own timezone. We thus adjust from UTC to the local timezome.
45 * https://stackoverflow.com/a/50537435
46 * https://groups.google.com/g/orthanc-users/c/dK7EEPVpedk/m/DPtMRFnKAgAJ
47 **/
48 var timezoneOffset = today.getTimezoneOffset() * 60 * 1000;
49 var localDate = new Date(utc.getTime() - timezoneOffset);
50
51 var s = localDate.toISOString();
52 return s.substring(0, 4) + s.substring(5, 7) + s.substring(8, 10);
46 } 53 }
47 54
48 55
49 $('#query-retrieve').live('pagebeforeshow', function() { 56 $('#query-retrieve').live('pagebeforeshow', function() {
50 var targetDate; 57 var targetDate;