util.js 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. "use strict";
  2. function formateDate(datetime, type) {
  3. const year = datetime.getFullYear();
  4. const month = String(datetime.getMonth() + 1).padStart(2, "0");
  5. const date = String(datetime.getDate()).padStart(2, "0");
  6. const hour = String(datetime.getHours()).padStart(2, "0");
  7. const minute = String(datetime.getMinutes()).padStart(2, "0");
  8. const second = String(datetime.getSeconds()).padStart(2, "0");
  9. switch (type) {
  10. case "Y-M-D h:min:s":
  11. return `${year}-${month}-${date} ${hour}:${minute}:${second}`;
  12. case "Y-M-D":
  13. return `${year}年${month}月${date}日`;
  14. case "h:min:s":
  15. return `${hour}:${minute}:${second}`;
  16. case "h":
  17. return hour;
  18. case "min":
  19. return minute;
  20. default:
  21. return "";
  22. }
  23. }
  24. function isSameDay(timeStampA) {
  25. const dateA = new Date(timeStampA);
  26. const dateB = /* @__PURE__ */ new Date();
  27. return dateA.setHours(0, 0, 0, 0) === dateB.setHours(0, 0, 0, 0);
  28. }
  29. exports.formateDate = formateDate;
  30. exports.isSameDay = isSameDay;
  31. //# sourceMappingURL=../../.sourcemap/mp-weixin/common/util.js.map