You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
399 B
18 lines
399 B
export function formatDate(value, format) {
|
|
if (!value) {
|
|
return '';
|
|
}
|
|
if (Array.isArray(format)) {
|
|
format = format[0];
|
|
}
|
|
if (typeof format === 'function') {
|
|
const result = format(value);
|
|
if (typeof result === 'string') {
|
|
return result;
|
|
} else {
|
|
throw new Error('The function of format does not return a string');
|
|
}
|
|
}
|
|
return value.format(format);
|
|
}
|