utils.js 502 B

1234567891011121314151617181920212223
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.formatDate = formatDate;
  6. function formatDate(value, format) {
  7. if (!value) {
  8. return '';
  9. }
  10. if (Array.isArray(format)) {
  11. format = format[0];
  12. }
  13. if (typeof format === 'function') {
  14. var result = format(value);
  15. if (typeof result === 'string') {
  16. return result;
  17. } else {
  18. throw new Error('The function of format does not return a string');
  19. }
  20. }
  21. return value.format(format);
  22. }