"use strict";
require("../common/vendor.js");
require("../request/http.js");
function accDiv(arg1, arg2) {
  var t1 = 0, t2 = 0, r1, r2;
  try {
    t1 = arg1.toString().split(".")[1].length;
  } catch (e) {
  }
  try {
    t2 = arg2.toString().split(".")[1].length;
  } catch (e) {
  }
  r1 = Number(arg1.toString().replace(".", ""));
  r2 = Number(arg2.toString().replace(".", ""));
  return accMul(r1 / r2, Math.pow(10, t2 - t1));
}
function accMul(arg1, arg2) {
  var m = 0, s1 = arg1.toString(), s2 = arg2.toString();
  try {
    m += s1.split(".")[1].length;
  } catch (e) {
  }
  try {
    m += s2.split(".")[1].length;
  } catch (e) {
  }
  return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m);
}
function accSub(arg1, arg2) {
  var r1, r2, m, n;
  try {
    r1 = arg1.toString().split(".")[1].length;
  } catch (e) {
    r1 = 0;
  }
  try {
    r2 = arg2.toString().split(".")[1].length;
  } catch (e) {
    r2 = 0;
  }
  m = Math.pow(10, Math.max(r1, r2));
  n = r1 >= r2 ? r1 : r2;
  return ((arg1 * m - arg2 * m) / m).toFixed(n);
}
function getRateStr(r) {
  if (!r)
    return;
  r = String(r);
  if (r.indexOf("-") > -1) {
    r = r.substr(1, r.length - 1);
    return parseFloat(r).toFixed(2);
  } else {
    if (parseFloat(r) == 0) {
      return 0;
    } else
      return parseFloat(r).toFixed(2);
  }
}
function getChgRateStr(r) {
  if (!r)
    return;
  r = String(r);
  if (r.indexOf("-") > -1) {
    r = r.substr(1, r.length - 1);
    return "-" + parseFloat(r).toFixed(2);
  } else {
    if (parseFloat(r) == 0) {
      return 0;
    } else
      return "+" + parseFloat(r).toFixed(2);
  }
}
function getRateUpOrDown(r) {
  if (!r)
    return;
  return String(r).indexOf("-") > -1;
}
function getLocaleTime(time) {
  if (time.indexOf("T") == -1) {
    time = time.replace(/-/g, "/");
  }
  let date = new Date(time);
  let year = date.getFullYear();
  let month = date.getMonth() + 1;
  let day = date.getDate();
  let hour = date.getHours();
  let minute = date.getMinutes();
  return year + "-" + (month < 10 ? "0" + month : month) + "-" + (day < 10 ? "0" + day : day) + " " + (hour < 10 ? "0" + hour : hour) + ":" + (minute < 10 ? "0" + minute : minute);
}
function getLocaleHourMinute(time) {
  if (time.indexOf("T") == -1) {
    time = time.replace(/-/g, "/");
  }
  let date = new Date(time);
  let hour = date.getHours();
  let minute = date.getMinutes();
  return (hour < 10 ? "0" + hour : hour) + ":" + (minute < 10 ? "0" + minute : minute);
}
function getLocaleMonthDayHourMinte(time) {
  if (time.indexOf("T") == -1) {
    time = time.replace(/-/g, "/");
  }
  let date = new Date(time);
  let month = date.getMonth() + 1;
  let day = date.getDate();
  let hour = date.getHours();
  let minute = date.getMinutes();
  return (month < 10 ? "0" + month : month) + "-" + (day < 10 ? "0" + day : day) + " " + (hour < 10 ? "0" + hour : hour) + ":" + (minute < 10 ? "0" + minute : minute);
}
function getLocalDate(time) {
  if (time.indexOf("T") == -1) {
    time = time.replace(/-/g, "/");
  }
  let date = new Date(time);
  let year = date.getFullYear();
  let month = date.getMonth() + 1;
  let day = date.getDate();
  return year + "-" + (month < 10 ? "0" + month : month) + "-" + (day < 10 ? "0" + day : day);
}
function replaceAnswerLabel(text) {
  return text.replace("<answer>", "").replace("</answer>", "");
}
exports.accDiv = accDiv;
exports.accMul = accMul;
exports.accSub = accSub;
exports.getChgRateStr = getChgRateStr;
exports.getLocalDate = getLocalDate;
exports.getLocaleHourMinute = getLocaleHourMinute;
exports.getLocaleMonthDayHourMinte = getLocaleMonthDayHourMinte;
exports.getLocaleTime = getLocaleTime;
exports.getRateStr = getRateStr;
exports.getRateUpOrDown = getRateUpOrDown;
exports.replaceAnswerLabel = replaceAnswerLabel;
//# sourceMappingURL=../../.sourcemap/mp-weixin/utils/util.js.map
