npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@openfate/true-solar-time

v4.0.2

Published

High-precision True Solar Time (真太阳时) calculator featuring Longitude Compensation and Equation of Time, extracted from OpenFate.ai core engine.

Readme


🌐 Overview

Standard time (Clock Time) is a political construct designed for social coordination. However, the physical sun position—the True Solar Time—depends precisely on your geographic longitude and the Earth's orbital variance.

@openfate/true-solar-time implements the rigorous Jean Meeus Astronomical Algorithms to calculate the physical apparent solar time with second-level precision, bridging the gap between political and physical time.

🚀 Key Capabilities

  • 🔭 High-Precision Engine – Based on Jean Meeus - Astronomical Algorithms for sub-minute accuracy.
  • 🌍 World-Class Timezone Resolution – Native IANA timezone support. Correctly handles Daylight Saving Time (DST) gaps, overlaps, and historical shifts.
  • 📐 Dual Engine Design – Toggle between the rigorous meeus engine (accuracy) and the approx engine (performance).
  • 🛡️ Robust & Verified – Over 20+ regression tests covering international date lines, century epochs, and complex timezone transitions.

📦 Installation

npm install @openfate/true-solar-time

📖 Usage Guide

A. Calculating from local wall-clock time

Use this if you have a local time and timezone (e.g., from a user input form).

import { calculateTrueSolarTime } from '@openfate/true-solar-time';

const result = calculateTrueSolarTime({
    year: 2024, month: 7, day: 1, hour: 12, minute: 0,
    timeZoneId: 'America/New_York'
}, {
    longitude: -74.006, // New York
    algorithm: 'meeus'
});

console.log(`Physically, the time is: ${result.trueSolarTime}`); // e.g., "11:43:22"

B. Calculating from a UTC Instant

Use this if you have an absolute Date object or a Unix timestamp.

import { getTrueSolarTimeFromInstant } from '@openfate/true-solar-time';

const result = getTrueSolarTimeFromInstant({
    date: new Date(),
    timeZoneId: 'Asia/Shanghai'
}, { longitude: 121.47 });

🛠️ API Reference

calculateTrueSolarTime(input, options)

The primary entry point. Resolves a civil (local) time to a true solar moment.

| Input Field | Type | Description | | :--- | :--- | :--- | | year, month, day | number | The calendar date. | | hour, minute | number | The wall-clock time. | | timeZoneId | string | IANA Timezone (e.g., Asia/Tokyo). | | timeZoneOffset | number? | Semi-fixed numeric offset in hours (optional). |

| Options | Type | Description | | :--- | :--- | :--- | | longitude | number | Precise longitude (East positive, West negative). | | algorithm | string | 'meeus' (default) or 'approx'. |

resolveCivilTime(input)

Low-level timezone resolver. Converts ambiguous local times (overlaps/gaps) into deterministic UTC instants.


🧪 Physics & Core Logic

The engine computes True Solar Time (真太阳时) using the following formula:

True Solar Time = Civil Time + Longitude Correction + Equation of Time (EoT) - DST

  1. Longitude Correction: Corrects the ~4 minute difference per 1° away from the timezone's standard meridian.
  2. Equation of Time (EoT): Corrects for the tilt of Earth's axis and its elliptical orbit around the sun.

🗺️ City Reference

| City | Longitude | Common Timezone | | :--- | :--- | :--- | | Beijing | 116.40 | UTC+8 | | Shanghai | 121.47 | UTC+8 | | London | 0.12 | UTC+0 | | New York | -74.00 | UTC-5 | | Tokyo | 139.69 | UTC+9 |


🔧 Development

npm test          # Run the 20+ regression test suite
npm run build     # Generate distribution files

📜 License

MIT — Engineered by OpenFate Engineering