From 228c6aff9a65a96d64a68f4f0aa52d518ee883f5 Mon Sep 17 00:00:00 2001 From: maliming Date: Thu, 27 Feb 2025 10:18:53 +0800 Subject: [PATCH] Refactor abp.js to use functions for timezone support and retrieval --- npm/packs/core/src/abp.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/npm/packs/core/src/abp.js b/npm/packs/core/src/abp.js index 9972039e2b..aca0196c15 100644 --- a/npm/packs/core/src/abp.js +++ b/npm/packs/core/src/abp.js @@ -748,9 +748,13 @@ var abp = abp || {}; abp.clock.kind = 'Unspecified'; - abp.clock.supportsMultipleTimezone = abp.clock.kind === 'Utc'; + abp.clock.supportsMultipleTimezone = function () { + return abp.clock.kind === 'Utc'; + } - abp.clock.timeZone = abp.setting.get('Abp.Timing.TimeZone'); + abp.clock.timeZone = function () { + return abp.setting.get('Abp.Timing.TimeZone'); + } // Normalize Date object or date string to standard string format that will be sent to server abp.clock.normalizeToString = function (date) { @@ -763,7 +767,7 @@ var abp = abp || {}; return date; } - if (abp.clock.supportsMultipleTimezone) { + if (abp.clock.supportsMultipleTimezone()) { return dateObj.toISOString(); } @@ -801,8 +805,8 @@ var abp = abp || {}; return dateString; } - if (abp.clock.supportsMultipleTimezone) { - var timezone = abp.clock.timeZone; + if (abp.clock.supportsMultipleTimezone()) { + var timezone = abp.clock.timeZone(); if (timezone) { options = options || {}; return date.toLocaleString(abp.localization.currentCulture.cultureName, Object.assign({}, abp.clock.toLocaleStringOptions, options, { timeZone: timezone }));