UNPKG

dragon-mobile-ui

Version:
41 lines (32 loc) 1.08 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; exports.default = formatFn; function getFormatter(type) { var formatter = void 0; if (type === 'year') { formatter = 'YYYY[年]'; } else if (type === 'month') { formatter = 'YYYY-MM'; } else if (type === 'time') { formatter = 'HH:mm'; } else if (type === 'datetime') { formatter = 'YYYY-MM-DD HH:mm'; } else { formatter = 'YYYY-MM-DD'; } return formatter; } function formatFn(instance, value) { var format = instance.props.format; var type = typeof format === 'undefined' ? 'undefined' : _typeof(format); if (type === 'string') { return value.format(format); } if (type === 'function') { return format(value); } return value.format(getFormatter(instance.props.mode)); }