"use strict"; const common_vendor = require("../common/vendor.js"); const getDate = (date, AddDayCount = 0) => { if (!date) { date = /* @__PURE__ */ new Date(); } if (typeof date !== "object") { date = date.replace(/-/g, "/"); } const dd = new Date(date); dd.setDate(dd.getDate() + AddDayCount); const y = dd.getFullYear(); const m = dd.getMonth() + 1 < 10 ? "0" + (dd.getMonth() + 1) : dd.getMonth() + 1; const d = dd.getDate() < 10 ? "0" + dd.getDate() : dd.getDate(); const dayStrList = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"]; const HMS = `${dd.getHours() < 10 ? "0" + dd.getHours() : dd.getHours()}${dd.getMinutes() < 10 ? "0" + dd.getMinutes() : dd.getMinutes()}${dd.getSeconds() < 10 ? "0" + dd.getSeconds() : dd.getSeconds()}`; return { fullDate: y + "-" + m + "-" + d, year: y, month: m, date: d, day: dd.getDay(), dayStr: dayStrList[dd.getDay()], rStr: `${m}月${d}日`, HMS }; }; function go(url, mode = "navigateTo") { if (url == -1) { let pages = getCurrentPages(); let beforePage = pages[pages.length - 2]; if (beforePage) { common_vendor.index.navigateBack(); } else { common_vendor.index.reLaunch({ url: "/pages/index/index" }); } } else { common_vendor.index[mode]({ url }); } } function sToHs(s) { let h; h = Math.floor(s / 60); s = s % 60; h += ""; s += ""; h = h.length === 1 ? "0" + h : h; s = Math.floor(s * 100) / 100; s = s.length === 1 ? "0" + s : s; if (parseInt(s) < 10) s = "0" + s; return "00:" + h + ":" + s; } function timeToMilliseconds(timeString) { const [hours, minutes, secondsWithMs] = timeString.split(":"); const [seconds, milliseconds] = secondsWithMs.split("."); const totalMilliseconds = parseInt(hours) * 3600 * 1e3 + // 小时转毫秒 parseInt(minutes) * 60 * 1e3 + // 分钟转毫秒 parseFloat(`${seconds}.${milliseconds}`) * 1e3; return totalMilliseconds; } function getTrackLength(str) { const milliseconds = timeToMilliseconds(str); return Math.round(milliseconds / 12.5); } const utils = { getDate, go, sToHs, timeToMilliseconds, getTrackLength }; exports.go = go; exports.utils = utils; //# sourceMappingURL=../../.sourcemap/mp-weixin/utils/utils.js.map