1 | import moment from 'moment';
|
2 |
|
3 | import { DISPLAY_FORMAT, ISO_FORMAT } from '../constants';
|
4 |
|
5 | export default function toMomentObject(dateString, customFormat) {
|
6 | const dateFormats = customFormat
|
7 | ? [customFormat, DISPLAY_FORMAT, ISO_FORMAT]
|
8 | : [DISPLAY_FORMAT, ISO_FORMAT];
|
9 |
|
10 | const date = moment(dateString, dateFormats, true);
|
11 | return date.isValid() ? date.hour(12) : null;
|
12 | }
|