export default (time, fmt) => {
  let format = fmt || "yyyy-MM-dd hh:mm";
  if (!time) {
    return "";
  }
  const date = new Date(parseInt(time, 10));
  const o = {
    "y+": date.getFullYear(),
    "M+": date.getMonth() + 1,
    "d+": date.getDate(),
    "h+": date.getHours(),
    "m+": date.getMinutes(),
    "s+": date.getSeconds()
  };

  for (const k in o) {
    if (new RegExp(`(${k})`).test(format)) {
      let str = o[k] + "";
      str = str.length > 1 ? str : 0 + str;
      format = format.replace(RegExp.$1, str);
    }
  }

  return format;
};
