|
|
import _ from 'lodash';
|
|
|
import moment from 'moment';
|
|
|
|
|
|
export default (value) => {
|
|
|
let format;
|
|
|
let unixStamp;
|
|
|
const isNum = _.isFinite(value);
|
|
|
const isObj = _.isPlainObject(value);
|
|
|
const defaultFmt = 'YYYY-MM-DD HH:mm:ss';
|
|
|
|
|
|
if (isNum) {
|
|
|
unixStamp = value;
|
|
|
format = defaultFmt;
|
|
|
} else if (isObj) {
|
|
|
unixStamp = value.time;
|
|
|
format = value.format || defaultFmt;
|
|
|
} else {
|
|
|
unixStamp = 'Invalid value.';
|
|
|
}
|
|
|
|
|
|
return moment.unix(unixStamp).format(format);
|
|
|
};
|
|
|
|
...
|
...
|
|