Skip to content

Commit

Permalink
Merge pull request #5474 from abpframework/liangshiwei/patch-1-startu…
Browse files Browse the repository at this point in the history
…p-templates

Add abp.luxon.js to startup templates
  • Loading branch information
maliming authored Sep 18, 2020
2 parents 0f01449 + 22c45fd commit 9f5d3fa
Show file tree
Hide file tree
Showing 35 changed files with 58,149 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
var abp = abp || {};
(function () {

if (!luxon) {
throw "abp/luxon library requires the luxon library included to the page!";
}

/* TIMING *************************************************/

abp.timing = abp.timing || {};

var setObjectValue = function (obj, property, value) {
if (typeof property === "string") {
property = property.split('.');
}

if (property.length > 1) {
var p = property.shift();
setObjectValue(obj[p], property, value);
} else {
obj[property[0]] = value;
}
}

var getObjectValue = function (obj, property) {
return property.split('.').reduce((a, v) => a[v], obj)
}

abp.timing.convertFieldsToIsoDate = function (form, fields) {
for (var field of fields) {
var dateTime = luxon.DateTime
.fromFormat(
getObjectValue(form, field),
abp.localization.currentCulture.dateTimeFormat.shortDatePattern,
{locale: abp.localization.currentCulture.cultureName}
);

if (!dateTime.invalid) {
setObjectValue(form, field, dateTime.toFormat("yyyy-MM-dd HH:mm:ss"))
}
}

return form;
}

})(jQuery);
Loading

0 comments on commit 9f5d3fa

Please sign in to comment.