Simplified <body> element references in DateTimeShortcuts.js.

This commit is contained in:
Jon Dufresne 2020-07-04 12:14:52 -07:00 committed by GitHub
parent 5d4b9c1cab
commit 4d9cd89acb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 4 deletions

View File

@ -28,8 +28,7 @@
timezoneWarningClass: 'timezonewarning', // class of the warning for timezone mismatch timezoneWarningClass: 'timezonewarning', // class of the warning for timezone mismatch
timezoneOffset: 0, timezoneOffset: 0,
init: function() { init: function() {
const body = document.getElementsByTagName('body')[0]; const serverOffset = document.body.dataset.adminUtcOffset;
const serverOffset = body.dataset.adminUtcOffset;
if (serverOffset) { if (serverOffset) {
const localOffset = new Date().getTimezoneOffset() * -60; const localOffset = new Date().getTimezoneOffset() * -60;
DateTimeShortcuts.timezoneOffset = localOffset - serverOffset; DateTimeShortcuts.timezoneOffset = localOffset - serverOffset;
@ -48,8 +47,7 @@
}, },
// Return the current time while accounting for the server timezone. // Return the current time while accounting for the server timezone.
now: function() { now: function() {
const body = document.getElementsByTagName('body')[0]; const serverOffset = document.body.dataset.adminUtcOffset;
const serverOffset = body.dataset.adminUtcOffset;
if (serverOffset) { if (serverOffset) {
const localNow = new Date(); const localNow = new Date();
const localOffset = localNow.getTimezoneOffset() * -60; const localOffset = localNow.getTimezoneOffset() * -60;