Browse Source

Merge pull request #22231 from abpframework/auto-merge/rel-9-0/3501

Merge branch rel-9.1 with rel-9.0
pull/22232/head
maliming 1 year ago
committed by GitHub
parent
commit
4ea2f4dae3
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 77
      npm/packs/core/src/abp.js

77
npm/packs/core/src/abp.js

@ -752,53 +752,56 @@ var abp = abp || {};
return abp.clock.kind === 'Utc'; return abp.clock.kind === 'Utc';
}; };
var toLocal = function (date) { // Normalize Date object or date string to standard string format that will be sent to server
return new Date( abp.clock.normalizeToString = function (date) {
date.getFullYear(), if (!date) {
date.getMonth(), return date;
date.getDate(),
date.getHours(),
date.getMinutes(),
date.getSeconds(),
date.getMilliseconds()
);
};
var toUtc = function (date) {
return Date.UTC(
date.getUTCFullYear(),
date.getUTCMonth(),
date.getUTCDate(),
date.getUTCHours(),
date.getUTCMinutes(),
date.getUTCSeconds(),
date.getUTCMilliseconds()
);
};
abp.clock.now = function () {
if (abp.clock.kind === 'Utc') {
return toUtc(new Date());
} }
return new Date();
};
abp.clock.normalize = function (date) {
var kind = abp.clock.kind;
if (kind === 'Unspecified') { var dateObj = date instanceof Date ? date : new Date(date);
if (isNaN(dateObj)) {
return date; return date;
} }
if (kind === 'Local') { if (abp.clock.kind === 'Utc') {
return toLocal(date); return dateObj.toISOString();
}
function padZero(num) {
return num < 10 ? '0' + num : num;
} }
if (kind === 'Utc') { function padMilliseconds(num) {
return toUtc(date); if (num < 10) return '00' + num;
if (num < 100) return '0' + num;
return num;
} }
// yyyy-MM-ddTHH:mm:ss.SSS
return dateObj.getFullYear() + '-' +
padZero(dateObj.getMonth() + 1) + '-' +
padZero(dateObj.getDate()) + 'T' +
padZero(dateObj.getHours()) + ':' +
padZero(dateObj.getMinutes()) + ':' +
padZero(dateObj.getSeconds()) + '.' +
padMilliseconds(dateObj.getMilliseconds());
}; };
// Normalize date string to locale date string that will be displayed to user
abp.clock.normalizeToLocaleString = function (dateString) {
if (!dateString) {
return dateString;
}
var date = new Date(dateString);
if (isNaN(date)) {
return dateString;
}
//TODO: Get timezone setting and pass it to toLocaleString
return date.toLocaleString();
}
/* FEATURES *************************************************/ /* FEATURES *************************************************/
abp.features = abp.features || {}; abp.features = abp.features || {};

Loading…
Cancel
Save