ant-design/components/date-picker/utils.ts

16 lines
343 B
TypeScript
Raw Normal View History

2019-05-07 14:57:32 +08:00
import * as moment from 'moment';
2019-08-14 18:21:24 +08:00
// eslint-disable-next-line import/prefer-default-export
2019-05-07 14:57:32 +08:00
export function formatDate(
value: moment.Moment | undefined | null,
format: string | string[] | undefined,
2019-05-07 14:57:32 +08:00
): string {
if (!value) {
return '';
}
if (Array.isArray(format)) {
format = format[0];
}
return value.format(format);
}