1
0

项目:模板更新

This commit is contained in:
周中平 2024-02-26 16:18:14 +08:00
parent eabb305fe7
commit 9d667e8300
Signed by: zhouzhongping
GPG Key ID: 6666822800008000
4 changed files with 45 additions and 9 deletions

36
Static/lunar_data.js Normal file
View 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;

View File

@ -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

View File

@ -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

View File

@ -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