Skip to main content
Glama
ISC License
188
172
index.ts1.36 kB
import { EightChar, LunarHour } from 'tyme4ts'; import { buildBazi } from './lib/bazi.js'; import { formatSolarTime, getSolarTime } from './lib/date.js'; export { getChineseCalendar } from './lib/chineseCalendar.js'; export const getBaziDetail = async (data: { lunarDatetime?; solarDatetime?; gender?; eightCharProviderSect? }) => { const { lunarDatetime, solarDatetime, gender, eightCharProviderSect } = data; if (!lunarDatetime && !solarDatetime) { throw new Error('solarDatetime和lunarDatetime必须传且只传其中一个。'); } let lunarHour: LunarHour; if (lunarDatetime) { const date = new Date(lunarDatetime); lunarHour = LunarHour.fromYmdHms( date.getFullYear(), date.getMonth() + 1, date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), ); } else { const solarTime = getSolarTime(solarDatetime!); lunarHour = solarTime.getLunarHour(); } return buildBazi({ lunarHour, gender: gender as 0 | 1, eightCharProviderSect: eightCharProviderSect as 1 | 2 }); }; export const getSolarTimes = async ({ bazi }) => { const [year, month, day, hour] = bazi.split(' '); const solarTimes = new EightChar(year, month, day, hour).getSolarTimes(1700, new Date().getFullYear()); const result = solarTimes.map((time) => formatSolarTime(time)); return result; };

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cantian-ai/bazi-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server