| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- <!DOCTYPE html>
- <html lang="zh-CN">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>万年历 - 全历法转换工具</title>
- <style>
- body {
- font-family: Arial, sans-serif;
- margin: 0;
- padding: 0;
- text-align: center;
- background-color: #f4f4f9;
- color: #333;
- }
- header {
- background-color: #4CAF50;
- color: white;
- padding: 10px 0;
- }
- .container {
- max-width: 800px;
- margin: 20px auto;
- padding: 20px;
- background: white;
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
- border-radius: 8px;
- }
- input[type="date"] {
- padding: 10px;
- font-size: 16px;
- border: 1px solid #ccc;
- border-radius: 4px;
- margin: 10px 0;
- }
- .result {
- margin-top: 20px;
- }
- .result div {
- margin: 10px 0;
- }
- .history {
- margin-top: 30px;
- text-align: left;
- }
- .history h3 {
- color: #4CAF50;
- }
- footer {
- margin-top: 20px;
- padding: 10px;
- background-color: #4CAF50;
- color: white;
- }
- </style>
- </head>
- <body>
- <header>
- <h1>万年历 - 全历法转换工具</h1>
- </header>
- <div class="container">
- <label for="date-input">选择日期:</label>
- <input type="date" id="date-input" />
- <div class="result">
- <h2>转换结果:</h2>
- <div id="gregorian-result">公历:--</div>
- <div id="chinese-result">农历:--</div>
- <div id="islamic-result">伊斯兰历:--</div>
- <div id="jewish-result">犹太历:--</div>
- <div id="maya-result">玛雅历:--</div>
- </div>
- </div>
- <footer>
- <p>© 2025 万年历工具 - 全历法转换</p>
- </footer>
- <script>
- document.getElementById("date-input").addEventListener("change", function() {
- const date = new Date(this.value);
- if (!isNaN(date)) {
- updateResults(date);
- } else {
- alert("请选择一个有效的日期!");
- }
- });
- function updateResults(date) {
- // 公历
- document.getElementById("gregorian-result").textContent = "公历:" + date.toDateString();
- // 农历
- const lunarDate = toChineseLunar(date);
- document.getElementById("chinese-result").textContent = "农历:" + lunarDate;
- // 伊斯兰历
- const islamicDate = toIslamicDate(date);
- document.getElementById("islamic-result").textContent = "伊斯兰历:" + islamicDate;
- // 犹太历
- const jewishDate = toJewishDate(date);
- document.getElementById("jewish-result").textContent = "犹太历:" + jewishDate;
- // 玛雅历
- const mayaDate = toMayaDate(date);
- document.getElementById("maya-result").textContent = "玛雅历:" + mayaDate;
- }
- function toChineseLunar(date) {
- // 农历计算逻辑(简单示例)
- const lunarMonths = ["正月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "冬月", "腊月"];
- const lunarDays = ["初一", "初二", "初三", "初四", "初五", "初六", "初七", "初八", "初九", "初十", "十一", "十二", "十三", "十四", "十五"];
- const year = date.getFullYear();
- const month = lunarMonths[(date.getMonth() % 12)];
- const day = lunarDays[(date.getDate() % 30)];
- return `${year}年 ${month} ${day}`;
- }
- function toIslamicDate(date) {
- // 伊斯兰历转换(简单示例)
- const jd = Math.floor((date - new Date("622-07-16")) / (24 * 60 * 60 * 1000)) + 1948439;
- const islamicYear = Math.floor((30 * jd + 10646) / 10631);
- const islamicMonth = Math.min(12, Math.ceil((jd - (29 + toJulian(islamicYear - 1, 1, 1))) / 29.5 + 1));
- const islamicDay = jd - toJulian(islamicYear, islamicMonth, 1) + 1;
- return `${islamicYear}年 ${islamicMonth}月 ${islamicDay}日`;
- }
- function toJewishDate(date) {
- // 犹太历(简单示例)
- return "5785年 尼散月";
- }
- function toMayaDate(date) {
- // 玛雅历(简单示例)
- return "13.0.0.0.0";
- }
- function toJulian(year, month, day) {
- return Math.floor(365.25 * year) + Math.floor(30.6001 * (month + 1)) + day + 1720994.5;
- }
- </script>
- </body>
- </html>
|