{"id":28639,"date":"2024-08-31T13:06:55","date_gmt":"2024-08-31T05:06:55","guid":{"rendered":"https:\/\/0592ban.cn\/?p=28639"},"modified":"2024-08-31T13:06:55","modified_gmt":"2024-08-31T05:06:55","slug":"%e4%b8%87%e5%b9%b4%e5%8e%86%e6%9f%a5%e8%af%a2%e8%a1%a8%e9%98%b4%e5%8e%861%e6%9c%888%e6%97%a5%e6%98%af%e5%87%a0%e5%8f%b7-%e4%b8%87%e5%b9%b4%e5%8e%86%e6%9f%a5%e8%af%a2%e8%a1%a8%e9%bb%84%e9%81%93","status":"publish","type":"post","link":"https:\/\/0592ban.cn\/index.php\/2024\/08\/31\/%e4%b8%87%e5%b9%b4%e5%8e%86%e6%9f%a5%e8%af%a2%e8%a1%a8%e9%98%b4%e5%8e%861%e6%9c%888%e6%97%a5%e6%98%af%e5%87%a0%e5%8f%b7-%e4%b8%87%e5%b9%b4%e5%8e%86%e6%9f%a5%e8%af%a2%e8%a1%a8%e9%bb%84%e9%81%93\/","title":{"rendered":"\u4e07\u5e74\u5386\u67e5\u8be2\u8868\u9634\u53861\u67088\u65e5\u662f\u51e0\u53f7? (\u4e07\u5e74\u5386\u67e5\u8be2\u8868\u9ec4\u9053\u5409\u65e5)"},"content":{"rendered":"<p><img decoding=\"async\" alt=\"\u4e07\u5e74\u5386\u67e5\u8be2\u8868\u9ec4\u9053\u5409\u65e5\" loading=\"lazy\" src=\"https:\/\/0592ban.cn\/wp-content\/uploads\/2024\/08\/c46935c3-2580-4e1b-b6ce-92f8f9653a81.jpg\"\/><\/p>\n<p>\n \u8bf7\u8f93\u5165\u8981\u67e5\u8be2\u7684\u516c\u5386\u65e5\u671f\uff1a\n<\/p>\n<form action=\"javascript:;\">\n <input id=\"inputDate\" type=\"date\"\/><br \/>\n <input type=\"submit\" value=\"\u67e5\u8be2\"\/><br \/>\n<\/form>\n<p>\n<script>\n const inputDate = document.getElementById(\"inputDate\");<\/p>\n<p>    inputDate.addEventListener(\"change\", function () {\n      const date = new Date(this.value);\n      const lunarDate = getLunarDate(date);<\/p>\n<p>      \/\/ \u6839\u636e\u516c\u5386\u65e5\u671f\u548c\u519c\u5386\u65e5\u671f\u8ba1\u7b97\u8ddd\u79bb\u6b63\u6708\u521d\u516b\u7684\u5929\u6570\n      const startDate = new Date(date.getFullYear(), 0, 1, 0, 0, 0, 0);\n      const daysFromStart = Math.floor((date - startDate) \/ (1000  60  60  24));\n      const daysFromLunarStart = Math.floor((lunarDate - startDate) \/ (1000  60  60  24));\n      const daysToChunji = 8 - daysFromLunarStart;\n      let chunjiDate;<\/p>\n<p>      if (daysToChunji > daysFromStart) {\n        chunjiDate = new Date(\n          date.getFullYear() + 1,\n          0,\n          8 - daysFromStart,\n          0,\n0,\n          0,\n          0\n        );\n      } else {\n        chunjiDate = new Date(date.getFullYear(), 0, 8 - daysToChunji, 0, 0, 0, 0);\n      }<\/p>\n<p>      \/\/ \u8f93\u51fa\u7ed3\u679c\n      const resultElement = document.getElementById(\"result\");\n      resultElement.innerHTML = `<\/p>\n<table border=\"1\">\n<thead>\n<tr>\n<th>\u516c\u5386\u65e5\u671f<\/th>\n<th>\u519c\u5386\u65e5\u671f<\/th>\n<th>\u5929\u5e72\u5730\u652f<\/th>\n<th>\u661f\u671f<\/th>\n<th>\u751f\u8096<\/th>\n<th>\u661f\u5ea7<\/th>\n<th>\u8ddd\u79bb\u6b63\u6708\u521d\u516b<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>${date.toLocaleDateString()}<\/td>\n<td>${lunarDate.toLocaleDateString()}<\/td>\n<td>${lunarDate.get\u5e72\u652f()}<\/td>\n<td>${lunarDate.getDay()}<\/td>\n<td>${lunarDate.get\u751f\u8096()}<\/td>\n<td>${lunarDate.get\u661f\u5ea7()}<\/td>\n<p>            ${\n              daysToChunji >0\n                ? `<\/p>\n<td class=\"highlight\">${daysToChunji} \u5929\u540e\uff08${chunjiDate.toLocaleDateString()}\uff09<\/td>\n<p>`\n                : `<\/p>\n<td class=\"highlight\">${-daysToChunji} \u5929\u524d\uff08${chunjiDate.toLocaleDateString()}\uff09<\/td>\n<p>`\n            }\n          <\/tr>\n<\/tbody>\n<\/table>\n<p>    `;\n    });<\/p>\n<p>    \/\n      \u83b7\u53d6\u519c\u5386\u65e5\u671f\n      @param {Date} date \u516c\u5386\u65e5\u671f\n      @returns {Date} \u519c\u5386\u65e5\u671f\n     \/\n    function getLunarDate(date) {\n      const solarYear = date.getFullYear();\n      const solarMonth = date.getMonth() + 1;\n      const solarDay = date.getDate();<\/p>\n<p>      const lunarYear = 1900 + Math.floor((solarYear - 4) \/ 12);\n      const lunarMonth = (solarMonth + 12) % 12 + 1;\n      const lunarDay = solarDay;<\/p>\n<p>      const lunarDate = new Date(lunarYear, lunarMonth, lunarDay, 0, 0, 0, 0);<\/p>\n<p>      return lunarDate;\n    }\n<\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8bf7\u8f93\u5165\u8981\u67e5\u8be2\u7684\u516c\u5386\u65e5\u671f\uff0cconstinputDate=document.getElementById\uff0cinputDate\uff0cinputDate.addEventListener\uff0cchange\uff0cfunction\uff0cconstdate=newDate\uff0cthis.value\uff0cconstlunarDate=getLunarDate\uff0cdat&#8230;\u3002<\/p>\n","protected":false},"author":1,"featured_media":28638,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[12064],"class_list":["post-28639","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-12shengxiao","tag-12064"],"_links":{"self":[{"href":"https:\/\/0592ban.cn\/index.php\/wp-json\/wp\/v2\/posts\/28639","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=28639"}],"version-history":[{"count":1,"href":"https:\/\/0592ban.cn\/index.php\/wp-json\/wp\/v2\/posts\/28639\/revisions"}],"predecessor-version":[{"id":28640,"href":"https:\/\/0592ban.cn\/index.php\/wp-json\/wp\/v2\/posts\/28639\/revisions\/28640"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/0592ban.cn\/index.php\/wp-json\/wp\/v2\/media\/28638"}],"wp:attachment":[{"href":"https:\/\/0592ban.cn\/index.php\/wp-json\/wp\/v2\/media?parent=28639"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/0592ban.cn\/index.php\/wp-json\/wp\/v2\/categories?post=28639"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/0592ban.cn\/index.php\/wp-json\/wp\/v2\/tags?post=28639"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}