All files / platform/core/src/utils formatDate.js

100% Statements 1/1
100% Branches 3/3
100% Functions 1/1
100% Lines 1/1

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15                        368x    
import moment from 'moment';
import i18n from 'i18next';
 
/**
 * Format date
 *
 * @param {string} date Date to be formatted
 * @param {string} format Desired date format
 * @returns {string} Formatted date
 */
export default (date, format = i18n.t('Common:localDateFormat','DD-MMM-YYYY')) => {
  // moment(undefined) returns the current date, so return the empty string instead
  return date ? moment(date).format(format) : '';
};