timeFormat.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. Object.defineProperty(exports, "__esModule", {
  2. value: !0
  3. });
  4. var e = exports.formatTime = function(e) {
  5. return {
  6. year: e.getFullYear(),
  7. month: e.getMonth() + 1,
  8. day: e.getDate(),
  9. hour: e.getHours(),
  10. minute: e.getMinutes(),
  11. second: e.getSeconds(),
  12. weekday: e.getDay()
  13. };
  14. },
  15. t = (exports.formatYMDLocal = function(r) {
  16. var n = e(r);
  17. return [n.year, n.month, n.day].map(t).join("/");
  18. }, exports.formatYMD = function(r) {
  19. var n = e(r);
  20. return [n.year, n.month, n.day].map(t).join("-");
  21. }, exports.formatHMS = function(r) {
  22. var n = e(r);
  23. return [n.hour, n.minute, n.second].map(t).join(":");
  24. }, exports.formatWithoutSecond = function(r) {
  25. var n = e(r);
  26. return [n.year, n.month, n.day].map(t).join("-") + " " + [n.hour, n.minute].map(t).join(":");
  27. }, exports.formatFull = function(r) {
  28. var n = e(r);
  29. return [n.year, n.month, n.day].map(t).join("-") + " " + [n.hour, n.minute, n.second].map(t).join(":");
  30. }, exports.formatMD = function(r) {
  31. var n = e(r);
  32. return [n.month].map(t) + "月" + [n.day].map(t) + "日";
  33. }, exports.formatYMDPoint = function(r) {
  34. var n = e(r);
  35. return [n.year, n.month, n.day].map(t).join(".");
  36. }, exports.formatYMDHMPoint = function(r) {
  37. var n = e(r);
  38. return [n.year, n.month, n.day].map(t).join(".") + " " + [n.hour, n.minute].map(t).join(":");
  39. }, exports.formatMDHM = function(r) {
  40. var n = e(r);
  41. return [n.month].map(t) + "." + [n.day].map(t) + " " + [n.hour, n.minute].map(t).join(":");
  42. }, exports.formatWeekday = function(t) {
  43. var r = e(t),
  44. n = "";
  45. switch (r.weekday) {
  46. case 0:
  47. n = "周日";
  48. break;
  49. case 1:
  50. n = "周一";
  51. break;
  52. case 2:
  53. n = "周二";
  54. break;
  55. case 3:
  56. n = "周三";
  57. break;
  58. case 4:
  59. n = "周四";
  60. break;
  61. case 5:
  62. n = "周五";
  63. break;
  64. case 6:
  65. n = "周六";
  66. }
  67. return r.weekday = n, r;
  68. }, exports.formatNumber = function(e) {
  69. return (e = e.toString())[1] ? e : "0" + e;
  70. });
  71. exports.getBeginTime = function(r, n) {
  72. var o = new Date(new Date(1 * n).getTime() + 864e5);
  73. o.setHours(0), o.setMinutes(0), o.setSeconds(0);
  74. var a = o.getTime(),
  75. u = e(new Date(1 * r));
  76. return a > r ? "今日" + [u.hour, u.minute].map(t).join(":") + "开抢" : a < r && a + 864e5 > r ? "明日" + [u.hour, u.minute].map(t).join(":") + "开抢" : "即将开抢";
  77. };