From 6ce39f41f7a04f2c9f7820f3dd94ed09c9edc6c7 Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Wed, 2 Sep 2020 10:30:19 +0300 Subject: [PATCH] bootstrap-taghelpers.abp.io npm packages updated related https://github.com/volosoft/volo/issues/3186 --- .../wwwroot/libs/abp/luxon/abp.luxon.js | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 framework/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo/wwwroot/libs/abp/luxon/abp.luxon.js diff --git a/framework/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo/wwwroot/libs/abp/luxon/abp.luxon.js b/framework/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo/wwwroot/libs/abp/luxon/abp.luxon.js new file mode 100644 index 0000000000..b04de7cadf --- /dev/null +++ b/framework/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo/wwwroot/libs/abp/luxon/abp.luxon.js @@ -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);