{"id":33462,"date":"2024-09-11T12:19:53","date_gmt":"2024-09-11T04:19:53","guid":{"rendered":"https:\/\/0592ban.cn\/?p=33462"},"modified":"2024-09-11T12:19:53","modified_gmt":"2024-09-11T04:19:53","slug":"1988%e5%b9%b4%e7%9a%84%e6%96%b0%e5%8e%868%e6%9c%8815%e6%97%a5%e6%98%af%e5%86%9c%e5%8e%86%e7%9a%84%e5%a4%9a%e5%b0%91-1988%e5%b9%b4%e7%9a%84%e9%be%99%e5%9c%a82024%e5%b9%b4%e7%9a%84%e8%bf%90%e5%8a%bf","status":"publish","type":"post","link":"https:\/\/0592ban.cn\/index.php\/2024\/09\/11\/1988%e5%b9%b4%e7%9a%84%e6%96%b0%e5%8e%868%e6%9c%8815%e6%97%a5%e6%98%af%e5%86%9c%e5%8e%86%e7%9a%84%e5%a4%9a%e5%b0%91-1988%e5%b9%b4%e7%9a%84%e9%be%99%e5%9c%a82024%e5%b9%b4%e7%9a%84%e8%bf%90%e5%8a%bf\/","title":{"rendered":"1988\u5e74\u7684\u65b0\u53868\u670815\u65e5\u662f\u519c\u5386\u7684\u591a\u5c11? (1988\u5e74\u7684\u9f99\u57282024\u5e74\u7684\u8fd0\u52bf\u600e\u4e48\u6837)"},"content":{"rendered":"<p><img decoding=\"async\" alt=\"1988\u5e74\u7684\u65b0\u53868\u670815\u65e5\u662f\u519c\u5386\u7684\u591a\u5c11?\" loading=\"lazy\" src=\"https:\/\/0592ban.cn\/wp-content\/uploads\/2024\/09\/fd6b8ef2-92af-42a8-b474-26765fd762a0.jpg\"\/><\/p>\n<div class=\"container\">\n<p>\n  \u8bf7\u8f93\u5165\u516c\u5386\u6216\u519c\u5386\u65e5\u671f\u8fdb\u884c\u67e5\u8be2\uff1a\n <\/p>\n<form class=\"date-picker\">\n  <label for=\"new-date\"><br \/>\n   \u516c\u5386\u65e5\u671f\uff1a<br \/>\n  <\/label><br \/>\n  <input id=\"new-date\" placeholder=\"\u5982\uff1a2023-03-08\" type=\"text\"\/><br \/>\n  <label for=\"lunar-date\"><br \/>\n   \u519c\u5386\u65e5\u671f\uff1a<br \/>\n  <\/label><br \/>\n  <input id=\"lunar-date\" placeholder=\"\u5982\uff1a2023\u5e74\u6b63\u6708\u521d\u4e00\" type=\"text\"\/><br \/>\n  <button type=\"submit\"><br \/>\n   \u67e5\u8be2<br \/>\n  <\/button><br \/>\n <\/form>\n<\/div>\n<p><script>\n constresult = document.getElementById('result');<\/p>\n<p>    const newDateInput = document.getElementById('new-date');\n    newDateInput.addEventListener('input', handleInputChange);<\/p>\n<p>    const lunarDateInput = document.getElementById('lunar-date');\n    lunarDateInput.addEventListener('input', handleInputChange);<\/p>\n<p>    function handleInputChange(e) {\n      result.classList.remove('show');<\/p>\n<p>      if (e.target.id === 'new-date') {\n        const newDate = e.target.value;\n        if (newDate) {\n          convertNewDateToLunarDate(newDate);\n        }\n      } else if (e.target.id === 'lunar-date') {\n        const lunarDate = e.target.value;\n        if (lunarDate) {\n          convertLunarDateToNewDate(lunarDate);\n        }\n      }\n    }<\/p>\n<p>    function convertNewDateToLunarDate(newDate) {\n      const dateParts = newDate.split('-');\n      const year = parseInt(dateParts[0]);\n      const month = parseInt(dateParts[1]);\n      const day = parseInt(dateParts[2]);<\/p>\n<p>      const lunarDate = getLunarDate(year, month, day);<\/p>\n<p>      displayResult('\u516c\u5386\u65e5\u671f\uff1a', newDate, '\u519c\u5386\u65e5\u671f\uff1a', lunarDate);\n    }<\/p>\n<p>    function convertLunarDateToNewDate(lunarDate) {\n      const dateParts = lunarDate.split('\u5e74');\n      const year = parseInt(dateParts[0].replace('\u620a\u8fb0', '1988'));\n      let month = parseInt(dateParts[1].replace('\u4e03\u6708', '7'));\n      const day = parseInt(dateParts[2].replace('\u521d\u56db', '4'));<\/p>\n<p>      \/\/ \u519c\u5386\u7684\u6708\u4efd\u662f\u4ece1\u5f00\u59cb\uff0c\u516c\u5386\u7684\u6708\u4efd\u662f\u4ece0\u5f00\u59cb\uff0c\u9700\u8981\u505a\u8f6c\u6362\n      month -= 1;<\/p>\n<p>      const newDate = getNewDate(year, month, day);<\/p>\n<p>      displayResult('\u519c\u5386\u65e5\u671f\uff1a', lunarDate, '\u516c\u5386\u65e5\u671f\uff1a', newDate);\n    }<\/p>\n<p>    function displayResult(title1, date1, title2, date2) {\n      result.classList.add('show');<\/p>\n<p>      const resultTitle = result.querySelector('.result-title');\n      resultTitle.innerHTML = title1 + ' ' + date1 + ' - ' + title2 + ' ' + date2;<\/p>\n<p>      const resultContent = result.querySelector('.result-content');\n      resultContent.innerHTML = '';\n    }<\/p>\n<p>    \/\/ \u6839\u636e\u516c\u5386\u5e74\u6708\u65e5\u83b7\u53d6\u519c\u5386\u65e5\u671f\n    function getLunarDate(year, month, day) {\n      const n = new Date(year, month - 1, day);\n      const y = n.getFullYear();\n      const m = n.getMonth() + 1;\n      const d = n.getDate();\n      const tz = [-2, 9, 9, 9, 9, 2, 1, 1, 1, 1, -1, -1, -1, -1, -1, -2]; \/\/ \u65f6\u533a\n      const t = tz[Math.floor(Math.abs(year - 2000) \/ 12)] + (Math.floor(Math.abs(year - 2000) \/ 10)) - (Math.floor(Math.abs(year - 2000) \/ 100)) + (Math.floor(Math.abs(year - 2000) \/ 400));\n      const k = Math.floor(2551944.5 + 29.530588861  (n - new Date('1988\/1\/1'))) \/ 29.530588861 + 0.0001178 - t;\n      const a = k - Math.floor(k \/ 12);\n      const b = 12 - a + 1;\n      const c = Math.floor(k \/ 12) - 1;\n      const e = 31;\n      const f = Math.floor((k + n.getTimezoneOffset() \/ 60 - n.getTimezoneOffset() \/ 24) \/ 29.530588861);\n      const g = (k + n.getTimezoneOffset() \/ 60 - n.getTimezoneOffset() \/ 24) - e  f;\n      const s = jdToStr(g);\n      const mStr = b + '\u6708';\n      constdStr = s.substr(3);<\/p>\n<p>      return year + '\u5e74' + mStr + dStr;\n    }<\/p>\n<p>    \/\/ \u6839\u636e\u519c\u5386\u5e74\u6708\u65e5\u83b7\u53d6\u516c\u5386\u65e5\u671f\n    function getNewDate(year, month, day) {\n      const m = month + 1;\n      const n = new Date(year, 0, 1);\n      const t = n.getTime() + (day - 1)  24  60  60  1000;\n      return strToJd(t, m, n.getDay());\n    }<\/p>\n<p>    \/\/ \u5112\u7565\u65e5\u8f6c\u5b57\u7b26\u4e32\n    function jdToStr(jd) {\n      const idoy = Math.floor(jd) + 0.5;\n      const iy = Math.floor(idoy \/ 365.25);\n      let im = iy  12 + Math.floor((idoy - Math.floor(iy  365.25)) \/ 30.6001);\n      if (im > 12) {\n        im -= 12;\n        iy++;\n      }\n      let id = idoy - Math.floor(iy  365.25) - Math.floor((im - 1)  30.6001);\n      if (id === 0) {\n        id = 31;\n        im--;\n      }\n      return '\u521d\u4e00' + (id > 10 ? '' : '\u521d') + id;\n    }<\/p>\n<p>    \/\/ \u5b57\u7b26\u4e32\u8f6c\u5112\u7565\u65e5\n    function strToJd(t, m, w) {\n      const y = Math.floor(t \/ 365.25);\n      const f = (t - y  365.25) \/ 30.6001;\n      const d = (t - y  365.25) - Math.floor(f)  30.6001;\n      const n = Math.floor(t \/ 365.25) - Math.floor(t \/ 146097);\n      const a = 32044 + 1461  y + 367 Math.floor(y \/ 4) - 71  Math\n<\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8bf7\u8f93\u5165\u516c\u5386\u6216\u519c\u5386\u65e5\u671f\u8fdb\u884c\u67e5\u8be2\uff0c\u516c\u5386\u65e5\u671f\uff0c\u519c\u5386\u65e5\u671f\uff0c\u67e5\u8be2constresult=document.getElementById\uff0cresult\uff0cconstnewDateInput=document.getElementById\uff0cnew\uff0cdate\uff0cnewDateInput.addEventListener\uff0cinput\uff0chandleInp&#8230;\u3002<\/p>\n","protected":false},"author":1,"featured_media":33461,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[13761],"class_list":["post-33462","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-12shengxiao","tag-13761"],"_links":{"self":[{"href":"https:\/\/0592ban.cn\/index.php\/wp-json\/wp\/v2\/posts\/33462","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/0592ban.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/0592ban.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/0592ban.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/0592ban.cn\/index.php\/wp-json\/wp\/v2\/comments?post=33462"}],"version-history":[{"count":1,"href":"https:\/\/0592ban.cn\/index.php\/wp-json\/wp\/v2\/posts\/33462\/revisions"}],"predecessor-version":[{"id":33463,"href":"https:\/\/0592ban.cn\/index.php\/wp-json\/wp\/v2\/posts\/33462\/revisions\/33463"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/0592ban.cn\/index.php\/wp-json\/wp\/v2\/media\/33461"}],"wp:attachment":[{"href":"https:\/\/0592ban.cn\/index.php\/wp-json\/wp\/v2\/media?parent=33462"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/0592ban.cn\/index.php\/wp-json\/wp\/v2\/categories?post=33462"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/0592ban.cn\/index.php\/wp-json\/wp\/v2\/tags?post=33462"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}