项目:模板更新
This commit is contained in:
parent
eabb305fe7
commit
9d667e8300
36
Static/lunar_data.js
Normal file
36
Static/lunar_data.js
Normal file
@ -0,0 +1,36 @@
|
||||
const https = require("https");
|
||||
|
||||
/**
|
||||
* 获取并格式化当前日期的农历信息。
|
||||
* @returns {Promise<string>} 返回格式化后的农历信息。
|
||||
*/
|
||||
async function getLunarDate() {
|
||||
return new Promise((resolve, reject) => {
|
||||
const url = "https://api.timelessq.com/time";
|
||||
|
||||
https
|
||||
.get(url, (resp) => {
|
||||
let data = "";
|
||||
|
||||
resp.on("data", (chunk) => {
|
||||
data += chunk;
|
||||
});
|
||||
|
||||
resp.on("end", () => {
|
||||
const result = JSON.parse(data);
|
||||
if (result.errno === 0) {
|
||||
const lunar = result.data.lunar;
|
||||
const formattedLunarDate = `${lunar.cyclicalYear}${lunar.zodiac}年 ${lunar.cyclicalMonth}月 ${lunar.cyclicalDay}日 农历${lunar.cnMonth}${lunar.cnDay}`;
|
||||
resolve(formattedLunarDate);
|
||||
} else {
|
||||
reject("Failed to fetch lunar date");
|
||||
}
|
||||
});
|
||||
})
|
||||
.on("error", (err) => {
|
||||
reject("Error: " + err.message);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = getLunarDate;
|
@ -1,8 +1,8 @@
|
||||
## 🗓️ Info
|
||||
|
||||
| Date | Weather | Moon |
|
||||
| -------------- | ------------ | ---- |
|
||||
| <% tp.date.now("ddd HH:mm") %> | <% tp.user.wttr_weather(" 郑州 ", "units=m&format=%l+%t+%c&lang=zh") %> | <% tp.user.wttr_weather("郑州", "format=%m&lang=zh") %> |
|
||||
| Date | Lunar | Weather | Moon |
|
||||
| -------------- | ------------ | ---- | ---- |
|
||||
| <% tp.date.now("ddd HH:mm") %> | <% tp.user.lunar_data() %> | <% tp.user.wttr_weather(" 郑州 ", "units=m&format=%l+%t+%c&lang=zh") %> | <% tp.user.wttr_weather("郑州", "format=%m&lang=zh") %> |
|
||||
|
||||
## 😊 Emotions
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
## 📆 Info
|
||||
|
||||
| Date | Weather | Moon |
|
||||
| -------------- | ------------ | ---- |
|
||||
| <% tp.date.now("ddd HH:mm") %> | <% tp.user.wttr_weather("郑州", "units=m&format=%l+%t+%c&lang=zh") %> | <% tp.user.wttr_weather("郑州", "format=%m&lang=zh") %> |
|
||||
| Date | Lunar | Weather | Moon |
|
||||
| -------------- | ------------ | ---- | ---- |
|
||||
| <% tp.date.now("ddd HH:mm") %> | <% tp.user.lunar_data() %> | <% tp.user.wttr_weather("郑州", "units=m&format=%l+%t+%c&lang=zh") %> | <% tp.user.wttr_weather("郑州", "format=%m&lang=zh") %> |
|
||||
|
||||
## 🌟 Overview
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
## 📅 Info
|
||||
|
||||
| Date | Weather | Moon |
|
||||
| -------------- | ------------ | ---- |
|
||||
| <% tp.date.now("ddd HH:mm") %> | <% tp.user.wttr_weather("郑州", "units=m&format=%l+%t+%c&lang=zh") %> | <% tp.user.wttr_weather("郑州", "format=%m&lang=zh") %> |
|
||||
| Date | Lunar | Weather | Moon |
|
||||
| ------------------------------ | -------------------------- | ------------------------------------------------------------ | ------------------------------------------------------- |
|
||||
| <% tp.date.now("ddd HH:mm") %> | <% tp.user.lunar_data() %> | <% tp.user.wttr_weather("郑州", "units=m&format=%l+%t+%c&lang=zh") %> | <% tp.user.wttr_weather("郑州", "format=%m&lang=zh") %> |
|
||||
|
||||
## 📖 Daily
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user