Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Calendar] "get date" can return formatted date #3141

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 48 additions & 8 deletions src/definitions/modules/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -802,24 +802,64 @@
formattedDate: function (format, date) {
return module.helper.dateFormat(format || formatter[settings.type], date || module.get.date());
},
date: function () {
return module.helper.sanitiseDate($module.data(metadata.date)) || null;
date: function (format = '') {
if (!module.helper.sanitiseDate($module.data(metadata.date))) {
return null;
}

if (format === '') {
return module.helper.sanitiseDate($module.data(metadata.date));
}

return module.helper.dateFormat(format, $module.data(metadata.date));
Comment on lines +805 to +814
Copy link
Member

@lubber-de lubber-de Dec 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Default function parameter values are not supported in IE11 (which FUI 2.9.x still supports)
  2. I would reduce the call to the sanitisedate function
Suggested change
date: function (format = '') {
if (!module.helper.sanitiseDate($module.data(metadata.date))) {
return null;
}
if (format === '') {
return module.helper.sanitiseDate($module.data(metadata.date));
}
return module.helper.dateFormat(format, $module.data(metadata.date));
date: function (format) {
format = format || '';
var date = module.helper.sanitiseDate($module.data(metadata.date)) || null;
if (!date) {
return null;
}
if (format === '') {
return date;
}
return module.helper.dateFormat(format, date);

},
inputDate: function () {
return $input.val();
},
focusDate: function () {
return $module.data(metadata.focusDate) || null;
focusDate: function (format = '') {
if (!module.helper.sanitiseDate($module.data(metadata.focusDate))) {
return null;
}

if (format === '') {
return module.helper.sanitiseDate($module.data(metadata.focusDate));
}

return module.helper.dateFormat(format, $module.data(metadata.focusDate));
Comment on lines +819 to +828
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Default function parameter values are not supported in IE11 (which FUI 2.9.x still supports)
  2. I would reduced the call to the sanitisedate function
Suggested change
focusDate: function (format = '') {
if (!module.helper.sanitiseDate($module.data(metadata.focusDate))) {
return null;
}
if (format === '') {
return module.helper.sanitiseDate($module.data(metadata.focusDate));
}
return module.helper.dateFormat(format, $module.data(metadata.focusDate));
focusDate: function (format) {
format = format || '';
var focusDate = module.helper.sanitiseDate($module.data(metadata.focusDate)) || null;
if (!focusDate) {
return null;
}
if (format === '') {
return focusDate;
}
return module.helper.dateFormat(format, focusDate);

},
startDate: function () {
startDate: function (format = '') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default function parameter values are not supported in IE11 (which FUI 2.9.x still supports)

Suggested change
startDate: function (format = '') {
startDate: function (format) {

var startModule = module.get.calendarModule(settings.startCalendar);

return (startModule ? startModule.get.date() : $module.data(metadata.startDate)) || null;
if (startModule) {
return startModule.get.date(format);
}

if (!module.helper.sanitiseDate($module.data(metadata.startDate))) {
return null;
}

if (format === '') {
return module.helper.sanitiseDate($module.data(metadata.startDate));
}

return module.helper.dateFormat(format, $module.data(metadata.startDate));
Comment on lines +833 to +845
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Default function parameter values are not supported in IE11 (which FUI 2.9.x still supports)
  2. I would reduced the call to the sanitisedate function
Suggested change
if (startModule) {
return startModule.get.date(format);
}
if (!module.helper.sanitiseDate($module.data(metadata.startDate))) {
return null;
}
if (format === '') {
return module.helper.sanitiseDate($module.data(metadata.startDate));
}
return module.helper.dateFormat(format, $module.data(metadata.startDate));
format = format || '';
if (startModule) {
return startModule.get.date(format);
}
var startDate = module.helper.sanitiseDate($module.data(metadata.startDate)) || null;
if (!startDate) {
return null;
}
if (format === '') {
return startDate;
}
return module.helper.dateFormat(format, startDate);

},
endDate: function () {
endDate: function (format = '') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default function parameter values are not supported in IE11 (which FUI 2.9.x still supports)

Suggested change
endDate: function (format = '') {
endDate: function (format) {

var endModule = module.get.calendarModule(settings.endCalendar);

return (endModule ? endModule.get.date() : $module.data(metadata.endDate)) || null;
if (endModule) {
return endModule.get.date(format);
}

if (!module.helper.sanitiseDate($module.data(metadata.endDate))) {
return null;
}

if (format === '') {
return module.helper.sanitiseDate($module.data(metadata.endDate));
}

return module.helper.dateFormat(format, $module.data(metadata.endDate));
Comment on lines +850 to +862
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Default function parameter values are not supported in IE11 (which FUI 2.9.x still supports)
  2. I would reduced the call to the sanitisedate function
Suggested change
if (endModule) {
return endModule.get.date(format);
}
if (!module.helper.sanitiseDate($module.data(metadata.endDate))) {
return null;
}
if (format === '') {
return module.helper.sanitiseDate($module.data(metadata.endDate));
}
return module.helper.dateFormat(format, $module.data(metadata.endDate));
format = format || '';
if (endModule) {
return endModule.get.date(format);
}
var endDate = module.helper.sanitiseDate($module.data(metadata.endDate)) || null;
if (!endDate) {
return null;
}
if (format === '') {
return endDate;
}
return module.helper.dateFormat(format, endDate);

},
minDate: function () {
return $module.data(metadata.minDate) || null;
Expand Down
Loading