Browse Source

Update date-range-picker-extensions.js

pull/18693/head
Salih 3 years ago
parent
commit
98adf582b2
  1. 25
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/date-range-picker/date-range-picker-extensions.js

25
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/date-range-picker/date-range-picker-extensions.js

@ -163,10 +163,10 @@
}
}
function convertToMoment(value, options, dateFormat) {
function convertToMoment(value, options, dateFormat, isUtc) {
if(!value) {
// invalid date
return moment('');
return moment.invalid();
}
options = options || {};
@ -174,7 +174,7 @@
if (typeof value === 'string') {
for(var format of formats) {
var date = moment(value, format);
var date = isUtc ? moment.utc(value, format) : moment(value, format);
if(date.isValid()) {
return date;
}
@ -186,10 +186,10 @@
}
if(value.isLuxonDateTime) {
return moment(value.toISO());
return isUtc ? moment.utc(value.toISO()) : moment(value.toISO());
}
return moment(value);
return isUtc ? moment.utc(value) : moment(value);
}
function getTodayButton(options, $dateRangePicker) {
@ -433,6 +433,15 @@
return '';
}
function createInitialAbpDate(date, options) {
date = convertToMoment(date, options, undefined, options.isUtc);
if (options.isUtc) {
date = date.local();
}
return AbpDate(date, options);
}
abp.dom.initializers.initializeDateRangePickers = function ($rootElement) {
$rootElement
@ -458,10 +467,10 @@
var singleOpenAndClearButton = options.singleOpenAndClearButton && $clearButton.length > 0 && $openButton.length > 0;
var startDate = AbpDate(options.startDate || options.date || (options.autoUpdateInput ? new Date() : undefined), options);
var startDate = createInitialAbpDate(options.startDate || options.date || (options.autoUpdateInput ? new Date() : undefined), options);
var oldStartDate = AbpDate(undefined, options);
var endDate = AbpDate(options.endDate || undefined, options);
var endDate = createInitialAbpDate(options.endDate || (options.autoUpdateInput ? new Date() : undefined), options);
var oldEndDate = AbpDate(undefined, options);
options.startDate = convertToMoment(startDate, options);

Loading…
Cancel
Save