@react-form-fields/native-base
Version:
Native Base Form Fields
23 lines • 904 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var format = require("date-fns/format");
var defaultFormats = {
date: 'yyyy-MM-dd',
time: 'HH:mm',
dateTime: 'yyyy-MM-dd HH:mm'
};
function dateFormat(value, mode, config, customFormat) {
if (!value || !(value instanceof Date))
return '';
if (isNaN(value.getTime()))
return '';
var dateConfig = getConfigDate(config);
var formatString = customFormat || dateConfig.formats[mode] || defaultFormats[mode] || mode;
return format(value, formatString, dateConfig.dataFnsLocale ? { locale: dateConfig.dataFnsLocale } : null);
}
exports.dateFormat = dateFormat;
function getConfigDate(config) {
return tslib_1.__assign(tslib_1.__assign({}, (config.date || {})), { formats: (config.date || {}).formats || {} });
}
//# sourceMappingURL=dateFormat.js.map