Browse Source

Refactor date handling in abp.js and add normalizeString function for date formatting

pull/22226/head
liangshiwei 12 months ago
parent
commit
3f11b54f41
  1. 23
      npm/packs/core/src/abp.js

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

@ -765,7 +765,7 @@ var abp = abp || {};
};
var toUtc = function (date) {
return Date.UTC(
return new Date(Date.UTC(
date.getUTCFullYear(),
date.getUTCMonth(),
date.getUTCDate(),
@ -773,7 +773,7 @@ var abp = abp || {};
date.getUTCMinutes(),
date.getUTCSeconds(),
date.getUTCMilliseconds()
);
));
};
abp.clock.now = function () {
@ -799,6 +799,25 @@ var abp = abp || {};
}
};
abp.clock.normalizeString = function (dateString) {
var date = abp.clock.normalize(new Date(dateString));
var kind = abp.clock.kind;
if(kind === 'Local' || kind === 'Unspecified'){
return date.getFullYear() + "-" +
String(date.getMonth() + 1).padStart(2, "0") + "-" +
String(date.getDate()).padStart(2, "0") + "T" +
String(date.getHours()).padStart(2, "0") + ":" +
String(date.getMinutes()).padStart(2, "0") + ":" +
String(date.getSeconds()).padStart(2, "0") + ".000";
}
if(kind === 'Utc'){
return date.toISOString();
}
}
/* FEATURES *************************************************/
abp.features = abp.features || {};

Loading…
Cancel
Save