fateclear-solar-time is a small TypeScript library for calendar applications, time conversion tools, and AI assistants, maintained by Boyun FateClear. Its core purpose is to convert an input date, clock time, longitude, and time zone offset into local true solar time, while retaining itemized corrections such as longitude correction, equation of time, and daylight saving time status, so that applications can explain the conversion process.
Main capabilities include: true solar time calculation, with a default standard time zone offset of UTC+8, longitude correction calculated from longitude, and the equation of time for the day added on top; twenty-four solar term queries, returning the solar term index, Chinese, Traditional Chinese, English, solar ecliptic longitude, UTC time, and Beijing time; daylight saving time status determination, with built-in China 1986–1991 rules, with statuses including standard, dst, nonexistent, and ambiguous. In the result, trueSolar is a date-time field, trueSolarText and meanSolarText are formatted times, and utc is the corresponding UTC time; dstCorrectionMinutes, longitudeCorrectionMinutes, equationOfTimeMinutes, and totalCorrectionMinutes give each correction and the total correction.
Usage: requires Git, Node.js 18 or later, npm, and a TypeScript project that supports ESM. Install from GitHub source; the installation process compiles TypeScript via prepare and requires the ability to install the declared dependencies. v0.1.0 has been released. When calling trueSolarTime, pass parameters such as date, clock time, longitude, and time zone offset. The library comes with an MCP service; the configuration can be added to an MCP client that supports stdio, allowing AI assistants to call it via MCP; the client needs to be able to find Git, Node.js, and npx, and the first launch may need to fetch the GitHub source, download dependencies, and compile. datetime uses the YYYY-MM-DD HH:mm format, and true_solar_time also accepts a T separator and optional seconds.
Applicable scenarios: time conversion and display in calendar applications, time tools that need to explain the true solar time correction process, and providing true solar time and solar term query capabilities to AI assistants via MCP.
Limitations: This library only performs time conversion and calendar queries; it does not generate a complete Bazi chart, nor does it make astrological judgments. Automatic daylight saving time only has built-in China 1986–1991 rules and is applied when utcOffset is 8; it is not a global historical time zone database, nor does it identify countries by longitude; other regions should determine the standard offset and daylight saving time handling themselves. A daylight saving time status marker does not mean ambiguity has been eliminated; boundary times must be confirmed by the caller. Solar terms are calculated according to the apparent solar ecliptic longitude from astronomy-engine; a time format down to seconds does not mean the absolute error is less than 1 second; the source tests sample every 7 years from 1900–2100 and compare with tyme4ts, with a threshold of 2 minutes, which cannot be extrapolated as a guarantee for all years. The simple equation of time is an approximation; existing tests sample every 7 days in 2000 and compare with precise, with a threshold of 2 minutes, which is not an error commitment for all dates. This library uses the MIT license; the accompanying calendar data (1900–2100 solar terms, sexagenary cycle, and lunar calendar, provided as CSV/JSON) uses a separate CC BY 4.0 license.