{"id":1843,"date":"2024-05-30T17:24:38","date_gmt":"2024-05-30T09:24:38","guid":{"rendered":"https:\/\/0592ban.cn\/?p=1843"},"modified":"2024-05-30T17:24:38","modified_gmt":"2024-05-30T09:24:38","slug":"6%e7%82%b9%e5%87%ba%e7%94%9f%e5%b1%9e%e7%89%9b%e4%ba%94%e8%a1%8c%e5%bd%92%e5%b1%9e%e5%8f%8a%e7%bc%ba%e5%a4%b1%e4%ba%94%e8%a1%8c-1997%e5%b9%b412%e6%9c%888%e6%97%a5%e5%87%8c%e6%99%a85-%e5%b1%9e","status":"publish","type":"post","link":"https:\/\/0592ban.cn\/index.php\/2024\/05\/30\/6%e7%82%b9%e5%87%ba%e7%94%9f%e5%b1%9e%e7%89%9b%e4%ba%94%e8%a1%8c%e5%bd%92%e5%b1%9e%e5%8f%8a%e7%bc%ba%e5%a4%b1%e4%ba%94%e8%a1%8c-1997%e5%b9%b412%e6%9c%888%e6%97%a5%e5%87%8c%e6%99%a85-%e5%b1%9e\/","title":{"rendered":"6\u70b9\u51fa\u751f\u5c5e\u725b\u4e94\u884c\u5f52\u5c5e\u53ca\u7f3a\u5931\u4e94\u884c 1997\u5e7412\u67088\u65e5\u51cc\u66685 (\u5c5e\u725b\u516d\u70b9\u51fa\u751f)"},"content":{"rendered":"<p><img decoding=\"async\" alt=\"1997\u5e7412\u67088\u65e5\u51cc\u66685\" loading=\"lazy\" src=\"https:\/\/0592ban.cn\/wp-content\/uploads\/2024\/05\/2f3ce2b4-8947-4c6b-9911-7200876188ac.jpg\"\/><\/p>\n<p>\n \u672c\u9875\u9762\u63d0\u4f9b\u516b\u5b57\u4e94\u884c\u5206\u6790\uff0c\u8f93\u5165\u516b\u5b57\u6216\u51fa\u751f\u5e74\u6708\u65e5\u65f6\uff0c\u5373\u53ef\u83b7\u53d6\u4e94\u884c\u3001\u7eb3\u97f3\u3001\u65e5\u4e3b\u3001\u7528\u795e\u7b49\u4fe1\u606f\u3002\n<\/p>\n<h2>\n \u8f93\u5165\u4fe1\u606f<br \/>\n<\/h2>\n<form>\n <label for=\"birthday\"><br \/>\n  \u51fa\u751f\u5e74\u6708\u65e5\u65f6\uff1a<br \/>\n <\/label><br \/>\n <input id=\"birthday\" placeholder=\"\u4f8b\uff1a1997\u5e7410\u670816\u65e5\u51cc\u66685\u70b9\u534a\" type=\"text\"\/><br \/>\n <input type=\"submit\" value=\"\u5206\u6790\"\/><br \/>\n<\/form>\n<hr\/>\n<h2>\n \u5206\u6790\u7ed3\u679c<br \/>\n<\/h2>\n<p><script>\n \/\/ \u83b7\u53d6\u8868\u5355\u5143\u7d20\n    const form = document.querySelector('form');<\/p>\n<p>    \/\/ \u63d0\u4ea4\u8868\u5355\u65f6\u89e6\u53d1\n    form.addEventListener('submit', (event) => {\n      event.preventDefault();\n      const birthday = document.querySelector('birthday').value;\n      const result = document.querySelector('result');<\/p>\n<p>      \/\/ \u6839\u636e\u51fa\u751f\u5e74\u6708\u65e5\u65f6\u8ba1\u7b97\u516b\u5b57\n      const eightChars = getEightChars(birthday);<\/p>\n<p>      \/\/ \u83b7\u53d6\u4e94\u884c\u3001\u7eb3\u97f3\u3001\u65e5\u4e3b\u3001\u7528\u795e\u7b49\u4fe1\u606f\n      const analysisResult = analyzeEightChars(eightChars);<\/p>\n<p>      \/\/ \u663e\u793a\u5206\u6790\u7ed3\u679c\n      result.innerHTML = `<\/p>\n<p>\u516b\u5b57\uff1a${eightChars.join(' ')}<\/p>\n<p>\u4e94\u884c\uff1a${analysisResult.\u4e94\u884c}<\/p>\n<p>\u7eb3\u97f3\uff1a${analysisResult.\u7eb3\u97f3}<\/p>\n<p>\u65e5\u4e3b\uff1a${analysisResult.\u65e5\u4e3b}<\/p>\n<p>\u7528\u795e\uff1a${analysisResult.\u7528\u795e}<\/p>\n<p>      `;\n    });<\/p>\n<p>    \/\/ \u6839\u636e\u51fa\u751f\u5e74\u6708\u65e5\u65f6\u8ba1\u7b97\u516b\u5b57\n    function getEightChars(birthday) {\n      const date = new Date(birthday);\n      const year = date.getFullYear();\n      const month = date.getMonth() + 1;\n      const day = date.getDate();\n      const hour = date.getHours();<\/p>\n<p>      \/\/\u5e74\u4efd\u7684\u5929\u5e72\u5730\u652f\n      const yearTianGan = ['\u7532', '\u4e59', '\u4e19', '\u4e01', '\u620a', '\u5df1', '\u5e9a', '\u8f9b', '\u58ec', '\u7678'];\n      const yearDiZhi = ['\u5b50', '\u4e11', '\u5bc5', '\u536f', '\u8fb0', '\u5df3', '\u5348', '\u672a', '\u7533', '\u9149', '\u620c', '\u4ea5'];\n      const yearTianGanIndex = (year - 1900) % 10;\n      const yearDiZhiIndex = (year - 1900) % 12;<\/p>\n<p>      \/\/ \u6708\u4efd\u7684\u5929\u5e72\u5730\u652f\n      const monthTianGan = ['\u7532', '\u4e19', '\u620a', '\u5e9a', '\u58ec'];\n      const monthDiZhi = ['\u5bc5', '\u536f', '\u8fb0', '\u5df3', '\u5348'];\n      const monthTianGanIndex = (month - 1) % 5;\n      const monthDiZhiIndex = (month - 1) % 5;<\/p>\n<p>      \/\/ \u65e5\u671f\u7684\u5929\u5e72\u5730\u652f\n      const dayTianGan = ['\u7532', '\u4e19', '\u620a', '\u5e9a', '\u58ec'];\n      const dayDiZhi = ['\u5b50', '\u5bc5', '\u8fb0', '\u5348', '\u7533', '\u620c'];\n      const dayTianGanIndex = (day - 1) % 5;\n      const dayDiZhiIndex = (day - 1) % 6;<\/p>\n<p>      \/\/ \u65f6\u8fb0\u7684\u5929\u5e72\u5730\u652f\n      const hourTianGan = ['\u7532', '\u4e19', '\u620a', '\u5e9a', '\u58ec'];\n      const hourDiZhi = ['\u5b50', '\u5bc5', '\u8fb0', '\u5348', '\u7533', '\u620c'];\n      const hourTianGanIndex = (hour - 1) % 5;\n      const hourDiZhiIndex = (hour - 1) % 6;<\/p>\n<p>      return [\n        yearTianGan[yearTianGanIndex] + yearDiZhi[yearDiZhiIndex],\n        monthTianGan[monthTianGanIndex] + monthDiZhi[monthDiZhiIndex],\n        dayTianGan[dayTianGanIndex] + dayDiZhi[dayDiZhiIndex],\n        hourTianGan[hourTianGanIndex] + hourDiZhi[hourDiZhiIndex],\n      ];\n    }<\/p>\n<p>    \/\/ \u6839\u636e\u516b\u5b57\u5206\u6790\u4e94\u884c\u3001\u7eb3\u97f3\u3001\u65e5\u4e3b\u3001\u7528\u795e\u7b49\u4fe1\u606f\n    function analyzeEightChars(eightChars) {\n      const wuXing = ['\u91d1', '\u6728', '\u6c34', '\u706b', '\u571f'];\n      const naYin = ['\u91d1\u7b94\u91d1', '\u5927\u6eaa\u6c34', '\u7802\u4e2d\u91d1', '\u5c71\u4e0b\u706b', '\u57ce\u5899\u571f',\n        '\u767d\u8721\u91d1', '\u6851\u677e\u6728', '\u6d1e\u4e0b\u6c34', '\u5c4b\u4e0a\u571f', '\u9739\u96f3\u706b',\n        '\u9497\u948f\u91d1', '\u677e\u67cf\u6728', '\u6da7\u4e0b\u6c34', '\u7530\u56ed\u571f', '\u7089\u4e2d\u706b'];<\/p>\n<p>      const result = {\n        \u4e94\u884c: '',\n        \u7eb3\u97f3: '',\n        \u65e5\u4e3b: '',\n        \u7528\u795e: '',\n      };<\/p>\n<p>      \/\/ \u8ba1\u7b97\u4e94\u884c\u4e2a\u6570\n      const wuXingCount = {};\n      for (const char of eightChars) {\n        const wuXingIndex = wuXing.indexOf(char[1]);\n        if (wuXingIndex >= 0) {\n          if (!wuXingCount[wuXingIndex]) {\n            wuXingCount[wuXingIndex] = 0;\n          }\n          wuXingCount[wuXingIndex]++;\n        }\n      }<\/p>\n<p>      \/\/ \u83b7\u53d6\u4e94\u884c\u4e2a\u6570\u6700\u591a\u7684\u5143\u7d20\n      let maxWuXingCount = 0;\n      let maxWuXingIndex = 0;\n      for (const key in wuXingCount) {\n        if (wuXingCount[key] > maxWuXingCount) {\n          maxWuXingCount = wuXingCount[key];\n          maxWuXingIndex = key;\n        }\n      }<\/p>\n<p>      \/\/ \u8bbe\u7f6e\u4e94\u884c\u548c\u65e5\u4e3b\n      result.\u4e94\u884c = wuXing.filter((e, i) => wuXingCount[i] > 0).join(' ');\n      result.\u65e5\u4e3b = wuXing[maxWuXingIndex];<\/p>\n<p>      \/\/ \u8ba1\u7b97\u7eb3\u97f3\n      const naYinIndex = (eightChars[0][0] + eightChars[1][0] + eightChars[2][0] + eightChars[3][0]) % 15;\n      result.\u7eb3\u97f3 = naYin[naYinIndex];<\/p>\n<p>      \/\/ \u8ba1\u7b97\u7528\u795e\n      const season = getSeason(eightChars[1][0]);\n      switch (result.\u65e5\u4e3b) {\n        case '\u91d1':\n          if (season === '\u6625' || season === '\u590f') {\n            result.\u7528\u795e= '\u6c34';\n          } else {\n            result.\u7528\u795e = '\u706b';\n          }\n          break;\n        case '\u6728':\n          if (season === '\u6625') {\n            result.\u7528\u795e = '\u706b';\n          } else if (season === '\u590f') {\n            result.\u7528\u795e = '\u91d1';\n          } else {\n            result.\u7528\u795e = '\u6c34';\n          }\n          break;\n        case '\u6c34':\n          if (season === '\u6625') {\n            result.\u7528\u795e = '\u6728';\n          } else if (season === '\u590f') {\n            result.\u7528\u795e = '\u571f';\n          } else {\n            result.\u7528\u795e = '\u91d1';\n          }\n          break;\n        case '\u706b':\n          if (season === '\u6625') {\n            result.\u7528\u795e = '\u91d1';\n          } else if (season === '\u590f') {\n            result.\u7528\u795e = '\u6728';\n          } else {\n            result.\u7528\u795e = '\u6c34';\n          }\n          break;\n        case '\u571f':\n          if (season === '\u6625') {\n            result.\u7528\u795e = '\u706b';\n          } else if (season === '\u590f') {\n            result.\u7528\u795e = '\u6728';\n          } else {\n            result.\u7528\u795e = '\u91d1';\n          }\n          break;\n      }<\/p>\n<p>      return result;\n    }<\/p>\n<p>    \/\/ \u6839\u636e\u6708\u4efd\u83b7\u53d6\u5b63\u8282\n    function getSeason(month) {\n      switch (month) {\n        case '\u5bc5':\n        case '\u536f':\n        case '\u8fb0':\nreturn '\u6625';\n        case '\u5df3':\n        case '\u5348':\n        case '\u672a':\n          return '\u590f';\n        case '\u7533':\n        case '\u9149':\n        case '\u620c':\n          return '\u79cb';\n        case '\u4ea5':\n        case '\u5b50':\n        case '\u4e11':\n          return '\u51ac';\n      }\n    }\n<\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u9875\u9762\u63d0\u4f9b\u516b\u5b57\u4e94\u884c\u5206\u6790\uff0c\u8f93\u5165\u516b\u5b57\u6216\u51fa\u751f\u5e74\u6708\u65e5\u65f6\uff0c\u5373\u53ef\u83b7\u53d6\u4e94\u884c\u3001\u7eb3\u97f3\u3001\u65e5\u4e3b\u3001\u7528\u795e\u7b49\u4fe1\u606f\uff0c\u8f93\u5165\u4fe1\u606f\u51fa\u751f\u5e74\u6708\u65e5\u65f6\uff0c\u5206\u6790\u7ed3\u679c\uff0c\u83b7\u53d6\u8868\u5355\u5143\u7d20constform=document.querySelector\uff0cform\uff0c\u63d0\u4ea4\u8868\u5355\u65f6\u89e6\u53d1form.addEventListener\uff0csubmit\uff0cevent\uff0c=\uff0cevent.preventDe&#8230;\u3002<\/p>\n","protected":false},"author":1,"featured_media":1842,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[1139,1140],"class_list":["post-1843","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-12shengxiao","tag-1139","tag-1140"],"_links":{"self":[{"href":"https:\/\/0592ban.cn\/index.php\/wp-json\/wp\/v2\/posts\/1843","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=1843"}],"version-history":[{"count":1,"href":"https:\/\/0592ban.cn\/index.php\/wp-json\/wp\/v2\/posts\/1843\/revisions"}],"predecessor-version":[{"id":1844,"href":"https:\/\/0592ban.cn\/index.php\/wp-json\/wp\/v2\/posts\/1843\/revisions\/1844"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/0592ban.cn\/index.php\/wp-json\/wp\/v2\/media\/1842"}],"wp:attachment":[{"href":"https:\/\/0592ban.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1843"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/0592ban.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1843"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/0592ban.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1843"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}