Birth chart systems such as Saju (Korean Four Pillars) and BaZi work from the time of birth. Most apps take the clock time from the birth certificate and use it as it is. That is often wrong by half an hour or more, because the clock follows a time zone and the chart follows the sun.
We needed this for Saju Lucky, so we wrote a small converter and published it under the MIT license: sajulucky/saju-solar-time. This post explains the three corrections it makes, shows the code, and lists the edge cases that took the most time.
Why the clock time is not enough
A Saju chart splits the day into 12 two-hour blocks. Each block gives a different Hour Pillar. 13:00 to 15:00 is one block and 15:00 to 17:00 is the next. Near a block edge, a 30 minute error moves the person into a different pillar.
Clock time drifts from the sun for three reasons:
- Daylight saving time. The clock is pushed one hour ahead of the sun.
- Longitude. A time zone is set by one meridian. Korea Standard Time is set at 135°E, but Seoul sits near 127°E. The sun reaches Seoul about 32 minutes after the clock says it should.
- The equation of time. The real sun runs up to about 16 minutes ahead of, or 14 minutes behind, the average sun across the year, because Earth's orbit is an ellipse and its axis is tilted.
True solar time is the clock time with all three corrections applied.
The formula
For a birth at longitude lon (east positive), in a zone whose standard offset from UTC is std minutes:
solar = clock - dst + (lon * 4 - std) + eot -
dstis 60 when daylight saving was in effect, else 0. -
lon * 4 - stdis the longitude correction. The sun moves 1° every 4 minutes, and a zone meridian in degrees isstd / 4. -
eotis the equation of time in minutes for that instant.
The hard parts are dst and std for a past date, and eot. The rest is arithmetic.
Install and use
The package is not on the npm registry yet, so install it from GitHub:
npm install github:sajulucky/saju-solar-time It has no dependencies and runs in Node 18+ and modern browsers.
import { trueSolarTime } from 'saju-solar-time'; const r = trueSolarTime({ year: 1990, month: 5, day: 15, hour: 14, minute: 30, longitude: 126.978, // Seoul timeZone: 'Asia/Seoul', }); console.log(r.iso); // 1990-05-15T14:01:36 console.log(r.corrections); // { // dstMinutes: 0, // longitudeMinutes: -32.088, // equationOfTimeMinutes: 3.69, // totalMinutes: -28.398 // } The result also carries utc (the moment of birth as a Date) and utcOffsetMinutes (the offset the clock used). If you have an offset but no IANA zone, pass utcOffsetMinutes: 540 in place of timeZone. Pass equationOfTime: false to get local mean time.
Three births where the Hour Pillar changes
These are real outputs from the code above.
| Birth (clock time) | Place | True solar time | Change | Hour block |
|---|---|---|---|---|
| 1 Jul 1988, 09:00 | Seoul | 07:24 | -96 min (DST, longitude, EoT) | 巳 (09-11) becomes 辰 (07-09) |
| 10 Jul 1995, 23:20 | New York | 22:18 | -61 min (DST, longitude, EoT) | 子 (23-01) becomes 亥 (21-23) |
| 3 Nov 1998, 12:50 | Chicago | 13:15 | +26 min (EoT, longitude) | 午 (11-13) becomes 未 (13-15) |
The Seoul case surprises people. South Korea used daylight saving in 1987 and 1988 (and in 1948 to 1951 and 1955 to 1960), so a summer birth in those years is off by more than 1.5 hours. From 1954 to 1961 Korea's standard time was UTC+8:30, which is one more reason never to hard-code offsets. The Chicago case runs the other way: in early November the equation of time is near its yearly peak of about +16 minutes, and Chicago sits east of its zone meridian at 90°W, so the sun is well ahead of the clock.
Edge case 1: knowing the offset on a past date
You cannot hard-code offsets. Zones change their rules, and some changed their standard offset outright. The runtime's time zone database already knows the history, and Intl.DateTimeFormat exposes it. Format a UTC instant in the target zone, read the parts back as if they were UTC, and the difference is the offset:
function utcOffsetMinutes(timeZone, ms) { const f = new Intl.DateTimeFormat('en-US', { timeZone, hourCycle: 'h23', year: 'numeric', month: 'numeric', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric', }); const p = {}; for (const part of f.formatToParts(new Date(ms))) p[part.type] = part.value; const wall = Date.UTC(+p.year, +p.month - 1, +p.day, +p.hour % 24, +p.minute, +p.second); return (wall - Math.floor(ms / 1000) * 1000) / 60000; } hourCycle: 'h23' matters. Without it some engines print midnight as 24.
Edge case 2: clock time to UTC
The input is a wall clock reading, but the offset depends on the UTC instant. Guess with the offset at the wall time read as UTC, then check once:
function wallToUtc(wallMs, timeZone) { const first = utcOffsetMinutes(timeZone, wallMs); let utc = wallMs - first * 60000; const second = utcOffsetMinutes(timeZone, utc); if (second !== first) utc = wallMs - second * 60000; return utc; } One correction is enough for real zones. A time inside a skipped daylight saving hour (02:30 on a spring-forward night) does not exist on the clock. The function still returns a result, so validate that input in your UI if it matters to you.
Edge case 3: telling daylight saving apart from a zone change
Intl gives the total offset, not "standard plus DST". The solar time itself does not need the split, since it is just UTC plus lon * 4 plus the equation of time. We split them only so the reported corrections read the way people expect: one hour of DST, then a longitude correction from the zone meridian. Our rule: take the lowest offset the zone used within 12 months either side of the birth as standard time, and count the gap as DST only when it is exactly 60 minutes.
function dstMinutesAt(timeZone, utc, offset) { let lowest = offset; for (let k = 1; k <= 12; k++) { const step = k * 30 * 86400000; lowest = Math.min(lowest, utcOffsetMinutes(timeZone, utc - step), utcOffsetMinutes(timeZone, utc + step)); } return offset - lowest === 60 ? 60 : 0; } If a zone moved its standard offset during that window, the gap is not 60 and stays inside the longitude correction. The final solar time comes out the same either way, because both corrections are added to the same clock.
Edge case 4: the equation of time
We use the formula from Jean Meeus, Astronomical Algorithms, chapter 28. It needs only the Julian date:
const RAD = Math.PI / 180; function equationOfTime(date) { const jd = date.getTime() / 86400000 + 2440587.5; const T = (jd - 2451545) / 36525; const L0 = (((280.46646 + T * (36000.76983 + 0.0003032 * T)) % 360) + 360) % 360 * RAD; const M = (357.52911 + T * (35999.05029 - 0.0001537 * T)) * RAD; const e = 0.016708634 - T * (0.000042037 + 0.0000001267 * T); const eps0 = 23 + (26 + (21.448 - T * (46.815 + T * (0.00059 - T * 0.001813))) / 60) / 60; const eps = (eps0 + 0.00256 * Math.cos((125.04 - 1934.136 * T) * RAD)) * RAD; const y = Math.tan(eps / 2) ** 2; const E = y * Math.sin(2 * L0) - 2 * e * Math.sin(M) + 4 * e * y * Math.sin(M) * Math.cos(2 * L0) - 0.5 * y * y * Math.sin(4 * L0) - 1.25 * e * e * Math.sin(2 * M); return 4 * E / RAD; // minutes, positive = sundial ahead of clock } We checked it against PyEphem on 72 dates from 1900 to 2090. The largest difference was 3.2 seconds, which is far below anything that could move a two-hour block.
Things this does not do
- It converts time only. It does not build or read a chart.
- Results for old dates are only as good as the time zone database in your runtime. Node ships full ICU data, so that is rarely a problem there.
- It needs the longitude of the birthplace. Our calculator page adds a place search on top, if you want to see it working without writing code.
Try it
- Code: github.com/sajulucky/saju-solar-time
- Live calculator with birthplace search: saju.bazilucky.com/solar-time
- Why birth time zones and daylight saving matter for a chart, without the code: Born abroad or unsure of your birth time?
Issues and pull requests are welcome, especially test cases from time zones with unusual histories.
