mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Adds javascript function for rendering a date according to user preference
This commit is contained in:
parent
b19719516b
commit
c720c75b79
@ -7,6 +7,7 @@
|
||||
clearEvents,
|
||||
endDate,
|
||||
startDate,
|
||||
renderDate,
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -32,3 +33,29 @@ function clearEvents(calendar) {
|
||||
event.remove();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Render the provided date in the user-specified format.
|
||||
*
|
||||
* The provided "date" variable is a string, nominally ISO format e.g. 2022-02-22
|
||||
* The user-configured setting DATE_DISPLAY_FORMAT determines how the date should be displayed.
|
||||
*/
|
||||
|
||||
function renderDate(date) {
|
||||
|
||||
if (!date) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var fmt = user_settings.DATE_DISPLAY_FORMAT || 'YYYY-MM-DD';
|
||||
|
||||
var m = moment(date);
|
||||
|
||||
if (m.isValid()) {
|
||||
return m.format(fmt);
|
||||
} else {
|
||||
// Invalid input string, simply return provided value
|
||||
return date;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user