@typescriptify/sweph 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/README.md +422 -0
  2. package/ephe/semo_18.se1 +0 -0
  3. package/ephe/sepl_18.se1 +0 -0
  4. package/originalCode/.eslintrc.json +124 -0
  5. package/originalCode/.gitattributes +2 -0
  6. package/originalCode/.github/FUNDING.yml +5 -0
  7. package/originalCode/.github/workflows/test.yml +35 -0
  8. package/originalCode/LICENSE +840 -0
  9. package/originalCode/README.md +91 -0
  10. package/originalCode/binding.gyp +41 -0
  11. package/originalCode/constants.js +366 -0
  12. package/originalCode/docs.gif +0 -0
  13. package/originalCode/index.d.ts +5115 -0
  14. package/originalCode/index.js +7 -0
  15. package/originalCode/index.mjs +109 -0
  16. package/originalCode/package.json +55 -0
  17. package/originalCode/src/functions/azalt.cpp +39 -0
  18. package/originalCode/src/functions/azalt_rev.cpp +35 -0
  19. package/originalCode/src/functions/calc.cpp +29 -0
  20. package/originalCode/src/functions/calc_pctr.cpp +31 -0
  21. package/originalCode/src/functions/calc_ut.cpp +29 -0
  22. package/originalCode/src/functions/close.cpp +6 -0
  23. package/originalCode/src/functions/cotrans.cpp +26 -0
  24. package/originalCode/src/functions/cotrans_sp.cpp +26 -0
  25. package/originalCode/src/functions/cs2degstr.cpp +19 -0
  26. package/originalCode/src/functions/cs2lonlatstr.cpp +23 -0
  27. package/originalCode/src/functions/cs2timestr.cpp +23 -0
  28. package/originalCode/src/functions/csnorm.cpp +15 -0
  29. package/originalCode/src/functions/csroundsec.cpp +15 -0
  30. package/originalCode/src/functions/d2l.cpp +15 -0
  31. package/originalCode/src/functions/date_conversion.cpp +30 -0
  32. package/originalCode/src/functions/day_of_week.cpp +15 -0
  33. package/originalCode/src/functions/degnorm.cpp +15 -0
  34. package/originalCode/src/functions/deltat.cpp +15 -0
  35. package/originalCode/src/functions/deltat_ex.cpp +24 -0
  36. package/originalCode/src/functions/difcs2n.cpp +19 -0
  37. package/originalCode/src/functions/difcsn.cpp +19 -0
  38. package/originalCode/src/functions/difdeg2n.cpp +19 -0
  39. package/originalCode/src/functions/difdegn.cpp +19 -0
  40. package/originalCode/src/functions/fixstar.cpp +32 -0
  41. package/originalCode/src/functions/fixstar2.cpp +32 -0
  42. package/originalCode/src/functions/fixstar2_mag.cpp +28 -0
  43. package/originalCode/src/functions/fixstar2_ut.cpp +32 -0
  44. package/originalCode/src/functions/fixstar_mag.cpp +28 -0
  45. package/originalCode/src/functions/fixstar_ut.cpp +32 -0
  46. package/originalCode/src/functions/gauquelin_sector.cpp +44 -0
  47. package/originalCode/src/functions/get_ayanamsa.cpp +15 -0
  48. package/originalCode/src/functions/get_ayanamsa_ex.cpp +27 -0
  49. package/originalCode/src/functions/get_ayanamsa_ex_ut.cpp +27 -0
  50. package/originalCode/src/functions/get_ayanamsa_name.cpp +19 -0
  51. package/originalCode/src/functions/get_ayanamsa_ut.cpp +15 -0
  52. package/originalCode/src/functions/get_current_file_data.cpp +28 -0
  53. package/originalCode/src/functions/get_library_path.cpp +8 -0
  54. package/originalCode/src/functions/get_orbital_elements.cpp +29 -0
  55. package/originalCode/src/functions/get_planet_name.cpp +19 -0
  56. package/originalCode/src/functions/get_tid_acc.cpp +7 -0
  57. package/originalCode/src/functions/heliacal_pheno_ut.cpp +52 -0
  58. package/originalCode/src/functions/heliacal_ut.cpp +52 -0
  59. package/originalCode/src/functions/helio_cross.cpp +33 -0
  60. package/originalCode/src/functions/helio_cross_ut.cpp +33 -0
  61. package/originalCode/src/functions/house_name.cpp +20 -0
  62. package/originalCode/src/functions/house_pos.cpp +36 -0
  63. package/originalCode/src/functions/houses.cpp +35 -0
  64. package/originalCode/src/functions/houses_armc.cpp +38 -0
  65. package/originalCode/src/functions/houses_armc_ex2.cpp +47 -0
  66. package/originalCode/src/functions/houses_ex.cpp +37 -0
  67. package/originalCode/src/functions/houses_ex2.cpp +46 -0
  68. package/originalCode/src/functions/jdet_to_utc.cpp +38 -0
  69. package/originalCode/src/functions/jdut1_to_utc.cpp +38 -0
  70. package/originalCode/src/functions/julday.cpp +25 -0
  71. package/originalCode/src/functions/lat_to_lmt.cpp +27 -0
  72. package/originalCode/src/functions/lmt_to_lat.cpp +27 -0
  73. package/originalCode/src/functions/lun_eclipse_how.cpp +34 -0
  74. package/originalCode/src/functions/lun_eclipse_when.cpp +31 -0
  75. package/originalCode/src/functions/lun_eclipse_when_loc.cpp +39 -0
  76. package/originalCode/src/functions/lun_occult_when_glob.cpp +35 -0
  77. package/originalCode/src/functions/lun_occult_when_loc.cpp +43 -0
  78. package/originalCode/src/functions/lun_occult_where.cpp +34 -0
  79. package/originalCode/src/functions/mooncross.cpp +26 -0
  80. package/originalCode/src/functions/mooncross_node.cpp +30 -0
  81. package/originalCode/src/functions/mooncross_node_ut.cpp +30 -0
  82. package/originalCode/src/functions/mooncross_ut.cpp +26 -0
  83. package/originalCode/src/functions/nod_aps.cpp +42 -0
  84. package/originalCode/src/functions/nod_aps_ut.cpp +42 -0
  85. package/originalCode/src/functions/orbit_max_min_true_distance.cpp +37 -0
  86. package/originalCode/src/functions/pheno.cpp +29 -0
  87. package/originalCode/src/functions/pheno_ut.cpp +29 -0
  88. package/originalCode/src/functions/radnorm.cpp +15 -0
  89. package/originalCode/src/functions/refrac.cpp +23 -0
  90. package/originalCode/src/functions/refrac_extended.cpp +32 -0
  91. package/originalCode/src/functions/revjul.cpp +33 -0
  92. package/originalCode/src/functions/rise_trans.cpp +44 -0
  93. package/originalCode/src/functions/rise_trans_true_hor.cpp +46 -0
  94. package/originalCode/src/functions/set_delta_t_userdef.cpp +14 -0
  95. package/originalCode/src/functions/set_ephe_path.cpp +14 -0
  96. package/originalCode/src/functions/set_jpl_file.cpp +14 -0
  97. package/originalCode/src/functions/set_sid_mode.cpp +20 -0
  98. package/originalCode/src/functions/set_tid_acc.cpp +14 -0
  99. package/originalCode/src/functions/set_topo.cpp +20 -0
  100. package/originalCode/src/functions/sidtime.cpp +15 -0
  101. package/originalCode/src/functions/sidtime0.cpp +21 -0
  102. package/originalCode/src/functions/sol_eclipse_how.cpp +34 -0
  103. package/originalCode/src/functions/sol_eclipse_when_glob.cpp +31 -0
  104. package/originalCode/src/functions/sol_eclipse_when_loc.cpp +39 -0
  105. package/originalCode/src/functions/sol_eclipse_where.cpp +30 -0
  106. package/originalCode/src/functions/solcross.cpp +26 -0
  107. package/originalCode/src/functions/solcross_ut.cpp +26 -0
  108. package/originalCode/src/functions/split_deg.cpp +35 -0
  109. package/originalCode/src/functions/time_equ.cpp +25 -0
  110. package/originalCode/src/functions/utc_time_zone.cpp +48 -0
  111. package/originalCode/src/functions/utc_to_jd.cpp +37 -0
  112. package/originalCode/src/functions/version.cpp +8 -0
  113. package/originalCode/src/functions/vis_limit_mag.cpp +50 -0
  114. package/originalCode/src/sweph.cpp +150 -0
  115. package/originalCode/src/sweph.h +119 -0
  116. package/originalCode/swisseph/swecl.c +6428 -0
  117. package/originalCode/swisseph/swedate.c +588 -0
  118. package/originalCode/swisseph/swedate.h +81 -0
  119. package/originalCode/swisseph/swehel.c +3511 -0
  120. package/originalCode/swisseph/swehouse.c +3143 -0
  121. package/originalCode/swisseph/swehouse.h +98 -0
  122. package/originalCode/swisseph/swejpl.c +958 -0
  123. package/originalCode/swisseph/swejpl.h +103 -0
  124. package/originalCode/swisseph/swemmoon.c +1930 -0
  125. package/originalCode/swisseph/swemplan.c +967 -0
  126. package/originalCode/swisseph/swemptab.h +10640 -0
  127. package/originalCode/swisseph/swenut2000a.h +2819 -0
  128. package/originalCode/swisseph/sweodef.h +326 -0
  129. package/originalCode/swisseph/sweph.c +8614 -0
  130. package/originalCode/swisseph/sweph.h +849 -0
  131. package/originalCode/swisseph/swephexp.h +1020 -0
  132. package/originalCode/swisseph/swephlib.c +4634 -0
  133. package/originalCode/swisseph/swephlib.h +189 -0
  134. package/package.json +28 -0
  135. package/scripts/gen-swemptab.js +177 -0
  136. package/scripts/gen-swenut2000a.js +106 -0
  137. package/src/SwissEph/README.md +268 -0
  138. package/src/SwissEph/UseCases/Ayanamsa.md +363 -0
  139. package/src/SwissEph/UseCases/AzimuthAltitude.md +408 -0
  140. package/src/SwissEph/UseCases/CoordinateSystems.md +337 -0
  141. package/src/SwissEph/UseCases/DateAndTime.md +368 -0
  142. package/src/SwissEph/UseCases/DeltaT.md +258 -0
  143. package/src/SwissEph/UseCases/EphemerisFiles.md +338 -0
  144. package/src/SwissEph/UseCases/FixedStars.md +300 -0
  145. package/src/SwissEph/UseCases/GauquelinSectors.md +304 -0
  146. package/src/SwissEph/UseCases/HeliacalEvents.md +396 -0
  147. package/src/SwissEph/UseCases/HelioCrossings.md +325 -0
  148. package/src/SwissEph/UseCases/HousePosition.md +254 -0
  149. package/src/SwissEph/UseCases/HouseSystems.md +279 -0
  150. package/src/SwissEph/UseCases/LunarEclipse.md +326 -0
  151. package/src/SwissEph/UseCases/MeridianTransit.md +279 -0
  152. package/src/SwissEph/UseCases/MoonCrossings.md +373 -0
  153. package/src/SwissEph/UseCases/NodesAndApsides.md +307 -0
  154. package/src/SwissEph/UseCases/Occultation.md +352 -0
  155. package/src/SwissEph/UseCases/OrbitalElements.md +469 -0
  156. package/src/SwissEph/UseCases/Phenomena.md +328 -0
  157. package/src/SwissEph/UseCases/PlanetPositions.md +366 -0
  158. package/src/SwissEph/UseCases/Planetocentric.md +278 -0
  159. package/src/SwissEph/UseCases/Refraction.md +314 -0
  160. package/src/SwissEph/UseCases/RiseAndSet.md +433 -0
  161. package/src/SwissEph/UseCases/SiderealTime.md +302 -0
  162. package/src/SwissEph/UseCases/SolarEclipse.md +379 -0
  163. package/src/SwissEph/UseCases/SunCrossings.md +275 -0
  164. package/src/SwissEph/UseCases/TopocentricCorrection.md +335 -0
  165. package/src/SwissEph/errors.ts +10 -0
  166. package/src/SwissEph/index.ts +823 -0
  167. package/src/SwissEph/types.ts +291 -0
  168. package/src/constants.ts +762 -0
  169. package/src/file-reader.ts +147 -0
  170. package/src/index.ts +10 -0
  171. package/src/swecl.ts +4526 -0
  172. package/src/swedate.ts +376 -0
  173. package/src/swehel.ts +1939 -0
  174. package/src/swehouse.ts +2167 -0
  175. package/src/swejpl.ts +470 -0
  176. package/src/swemmoon.ts +1318 -0
  177. package/src/swemplan.ts +585 -0
  178. package/src/swemptab.ts +4448 -0
  179. package/src/swenut2000a.ts +2763 -0
  180. package/src/sweph.ts +3993 -0
  181. package/src/swephlib.ts +2720 -0
  182. package/src/types.ts +490 -0
  183. package/tests/c-style/ayanamsa.test.ts +63 -0
  184. package/tests/c-style/config.test.ts +96 -0
  185. package/tests/c-style/crossings.test.ts +81 -0
  186. package/tests/c-style/date-time.test.ts +114 -0
  187. package/tests/c-style/eclipses.test.ts +84 -0
  188. package/tests/c-style/fixed-stars.test.ts +66 -0
  189. package/tests/c-style/heliacal.test.ts +34 -0
  190. package/tests/c-style/houses.test.ts +135 -0
  191. package/tests/c-style/math-utils.test.ts +160 -0
  192. package/tests/c-style/orbital.test.ts +78 -0
  193. package/tests/c-style/phenomena.test.ts +42 -0
  194. package/tests/c-style/planetocentric.test.ts +26 -0
  195. package/tests/c-style/planets.test.ts +117 -0
  196. package/tests/c-style/rise-set.test.ts +71 -0
  197. package/tests/helpers.ts +21 -0
  198. package/tests/modern/ayanamsa.test.ts +47 -0
  199. package/tests/modern/calc.test.ts +113 -0
  200. package/tests/modern/config.test.ts +46 -0
  201. package/tests/modern/crossings.test.ts +45 -0
  202. package/tests/modern/eclipses.test.ts +81 -0
  203. package/tests/modern/errors.test.ts +71 -0
  204. package/tests/modern/heliacal.test.ts +30 -0
  205. package/tests/modern/houses.test.ts +87 -0
  206. package/tests/modern/orbital.test.ts +79 -0
  207. package/tests/modern/phenomena.test.ts +41 -0
  208. package/tests/modern/rise-set.test.ts +60 -0
  209. package/tests/modern/statics.test.ts +99 -0
  210. package/tests/modern/utilities.test.ts +70 -0
  211. package/tsconfig.json +20 -0
@@ -0,0 +1,368 @@
1
+ # Date and Time
2
+
3
+ The **Julian Day** (JD) is a continuous day count used in astronomy. It counts the number of days (and fractions of a day) that have elapsed since **January 1, 4713 BC at noon** (in the Julian proleptic calendar). This system has no gaps for calendar reforms, no missing days, no ambiguity about time zones -- just a single number that increases steadily.
4
+
5
+ Despite the name, the Julian Day has **nothing to do with the Julian calendar**. The naming is a coincidence: the Julian Day system was devised by Joseph Scaliger in 1583 and named after his father Julius Caesar Scaliger, while the Julian calendar was named after the Roman dictator Julius Caesar. The similarity is purely in the name "Julius."
6
+
7
+ The Julian Day is the standard time input for the Swiss Ephemeris. Every calculation -- planet positions, eclipses, rise/set times -- takes a Julian Day number as its time parameter. This library provides utility methods to convert between familiar calendar dates and Julian Day numbers.
8
+
9
+ ---
10
+
11
+ ## Quick Example
12
+
13
+ ```typescript
14
+ import { SwissEph } from '../index';
15
+
16
+ // Convert a date to Julian Day
17
+ const jd = SwissEph.julianDay(2025, 6, 15, 12); // June 15, 2025 at noon UT
18
+ console.log(`Julian Day: ${jd}`);
19
+ // 2460811.0
20
+
21
+ // Convert back to a date
22
+ const date = SwissEph.fromJulianDay(jd);
23
+ console.log(`${date.year}-${date.month}-${date.day}, hour: ${date.hour}`);
24
+ // 2025-6-15, hour: 12
25
+
26
+ // Day of the week
27
+ const dow = SwissEph.dayOfWeek(jd);
28
+ const dayNames = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
29
+ console.log(`Day of week: ${dayNames[dow]}`);
30
+ ```
31
+
32
+ ---
33
+
34
+ ## Detailed Examples
35
+
36
+ ### Converting dates to Julian Day
37
+
38
+ The `julianDay()` method takes year, month, day, and fractional hour. Hours are expressed as decimal fractions of a day: 6.5 = 6:30 AM, 18.75 = 6:45 PM.
39
+
40
+ ```typescript
41
+ import { SwissEph } from '../index';
42
+
43
+ // J2000.0 epoch (January 1, 2000 at 12:00 TT)
44
+ const j2000 = SwissEph.julianDay(2000, 1, 1, 12);
45
+ console.log(`J2000.0: ${j2000}`);
46
+ // 2451545.0
47
+
48
+ // Midnight on January 1, 2025
49
+ const newYear = SwissEph.julianDay(2025, 1, 1, 0);
50
+ console.log(`2025 New Year midnight: ${newYear}`);
51
+
52
+ // A specific time: March 20, 2025 at 09:01:25 UT
53
+ // Convert h:m:s to fractional hours: 9 + 1/60 + 25/3600 = 9.02361...
54
+ const equinox = SwissEph.julianDay(2025, 3, 20, 9 + 1/60 + 25/3600);
55
+ console.log(`2025 vernal equinox: ${equinox.toFixed(6)}`);
56
+
57
+ // Negative years: 1 BC = year 0, 2 BC = year -1, etc.
58
+ // (Astronomical year numbering, not historical)
59
+ const ancient = SwissEph.julianDay(-3000, 7, 19, 12);
60
+ console.log(`July 19, 3001 BC: ${ancient}`);
61
+ ```
62
+
63
+ ### Converting Julian Day back to a date
64
+
65
+ ```typescript
66
+ import { SwissEph } from '../index';
67
+
68
+ const jd = 2460811.0; // some Julian Day
69
+
70
+ const date = SwissEph.fromJulianDay(jd);
71
+ console.log(`Year: ${date.year}`);
72
+ console.log(`Month: ${date.month}`);
73
+ console.log(`Day: ${date.day}`);
74
+ console.log(`Hour: ${date.hour}`); // fractional hour
75
+
76
+ // Convert fractional hour to h:m:s
77
+ const h = Math.floor(date.hour);
78
+ const m = Math.floor((date.hour - h) * 60);
79
+ const s = ((date.hour - h) * 60 - m) * 60;
80
+ console.log(`Time: ${h}:${String(m).padStart(2,'0')}:${s.toFixed(1).padStart(4,'0')}`);
81
+ ```
82
+
83
+ ### UTC conversions with utcToJd and jdToUtc
84
+
85
+ The `utcToJd()` method converts a UTC date/time to Julian Day numbers and returns **both** the ET (Ephemeris Time) and UT (Universal Time) values. This is important because the Swiss Ephemeris internally works in ET, but most users think in UT/UTC.
86
+
87
+ ```typescript
88
+ import { SwissEph } from '../index';
89
+
90
+ // Convert a precise UTC time to Julian Day
91
+ const result = SwissEph.utcToJd(2025, 3, 20, 9, 1, 25.0); // 2025-03-20 09:01:25 UTC
92
+
93
+ console.log(`JD (ET): ${result.tjdEt.toFixed(6)}`);
94
+ console.log(`JD (UT): ${result.tjdUt.toFixed(6)}`);
95
+ console.log(`Difference (ET - UT): ${((result.tjdEt - result.tjdUt) * 86400).toFixed(1)} seconds`);
96
+ // The difference is delta-T, about 69 seconds in 2025
97
+
98
+ // Convert JD (ET) back to UTC
99
+ const utcFromEt = SwissEph.jdToUtc(result.tjdEt);
100
+ console.log(`\nBack to UTC from ET:`);
101
+ console.log(` ${utcFromEt.year}-${utcFromEt.month}-${utcFromEt.day}`);
102
+ console.log(` ${utcFromEt.hour}:${utcFromEt.minute}:${utcFromEt.second.toFixed(3)}`);
103
+
104
+ // Convert JD (UT) back to UTC
105
+ const utcFromUt = SwissEph.jdUtToUtc(result.tjdUt);
106
+ console.log(`\nBack to UTC from UT:`);
107
+ console.log(` ${utcFromUt.year}-${utcFromUt.month}-${utcFromUt.day}`);
108
+ console.log(` ${utcFromUt.hour}:${utcFromUt.minute}:${utcFromUt.second.toFixed(3)}`);
109
+ ```
110
+
111
+ ### Day of the week
112
+
113
+ The `dayOfWeek()` method returns 0 for Monday through 6 for Sunday. It works for any Julian Day, including dates thousands of years in the past or future.
114
+
115
+ ```typescript
116
+ import { SwissEph } from '../index';
117
+
118
+ const dayNames = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
119
+
120
+ // What day of the week was July 20, 1969 (Apollo 11 landing)?
121
+ const apollo = SwissEph.julianDay(1969, 7, 20, 20.3); // ~20:17 UT
122
+ console.log(`Apollo 11 landing: ${dayNames[SwissEph.dayOfWeek(apollo)]}`);
123
+ // Sunday
124
+
125
+ // What day of the week is January 1, 2000?
126
+ const y2k = SwissEph.julianDay(2000, 1, 1, 0);
127
+ console.log(`Y2K: ${dayNames[SwissEph.dayOfWeek(y2k)]}`);
128
+ // Saturday
129
+
130
+ // Check a range of dates
131
+ console.log('\nFirst day of each month in 2025:');
132
+ for (let month = 1; month <= 12; month++) {
133
+ const jd = SwissEph.julianDay(2025, month, 1, 0);
134
+ console.log(` 2025-${String(month).padStart(2,'0')}-01: ${dayNames[SwissEph.dayOfWeek(jd)]}`);
135
+ }
136
+ ```
137
+
138
+ ### Gregorian vs Julian calendar
139
+
140
+ The `SE_GREG_CAL` (default) and `SE_JUL_CAL` flags control which calendar system is used. The Gregorian calendar was introduced by Pope Gregory XIII on October 15, 1582 (the day after October 4 in the Julian calendar -- 10 days were skipped). Different countries adopted it at different times.
141
+
142
+ ```typescript
143
+ import { SwissEph } from '../index';
144
+ import { SE_GREG_CAL, SE_JUL_CAL } from '../../constants';
145
+
146
+ // The same "date" in both calendars gives different Julian Days
147
+ // because the calendars diverge after the 1582 reform.
148
+
149
+ // October 15, 1582 -- first day of the Gregorian calendar
150
+ const gregStart = SwissEph.julianDay(1582, 10, 15, 12, SE_GREG_CAL);
151
+ console.log(`Oct 15, 1582 (Gregorian): JD ${gregStart}`);
152
+
153
+ // October 5, 1582 -- the Julian calendar day that corresponds to the same moment
154
+ const julSame = SwissEph.julianDay(1582, 10, 5, 12, SE_JUL_CAL);
155
+ console.log(`Oct 5, 1582 (Julian): JD ${julSame}`);
156
+ console.log(`Same day? ${gregStart === julSame}`); // true
157
+
158
+ // For ancient dates, always use SE_JUL_CAL
159
+ // The Battle of Marathon: September 12, 490 BC
160
+ const marathon = SwissEph.julianDay(-489, 9, 12, 12, SE_JUL_CAL);
161
+ const marathonDate = SwissEph.fromJulianDay(marathon, SE_JUL_CAL);
162
+ console.log(`\nMarathon: JD ${marathon}`);
163
+ console.log(`Verified: ${marathonDate.year}/${marathonDate.month}/${marathonDate.day}`);
164
+
165
+ // Note: In astronomical year numbering, 490 BC = year -489
166
+ // (there is a year 0 between 1 BC and 1 AD)
167
+ ```
168
+
169
+ ### Converting JD to local time
170
+
171
+ Julian Day numbers are in Universal Time (UT). To get local time, add the timezone offset as a fraction of a day (hours / 24).
172
+
173
+ ```typescript
174
+ import { SwissEph } from '../index';
175
+
176
+ // An event occurs at JD 2460811.25 (some UT time)
177
+ const jdUt = 2460811.25;
178
+
179
+ // Convert to calendar date in UT
180
+ const utDate = SwissEph.fromJulianDay(jdUt);
181
+ const utH = Math.floor(utDate.hour);
182
+ const utM = Math.floor((utDate.hour - utH) * 60);
183
+ console.log(`UT: ${utDate.year}-${utDate.month}-${utDate.day} ${utH}:${String(utM).padStart(2,'0')}`);
184
+
185
+ // Convert to New York time (EST = UT-5, EDT = UT-4)
186
+ const estOffset = -5; // EST
187
+ const jdLocal = jdUt + estOffset / 24;
188
+ const localDate = SwissEph.fromJulianDay(jdLocal);
189
+ const locH = Math.floor(localDate.hour);
190
+ const locM = Math.floor((localDate.hour - locH) * 60);
191
+ console.log(`EST: ${localDate.year}-${localDate.month}-${localDate.day} ${locH}:${String(locM).padStart(2,'0')}`);
192
+
193
+ // Convert to Tokyo time (JST = UT+9)
194
+ const jstOffset = 9;
195
+ const jdTokyo = jdUt + jstOffset / 24;
196
+ const tokyoDate = SwissEph.fromJulianDay(jdTokyo);
197
+ const tokH = Math.floor(tokyoDate.hour);
198
+ const tokM = Math.floor((tokyoDate.hour - tokH) * 60);
199
+ console.log(`JST: ${tokyoDate.year}-${tokyoDate.month}-${tokyoDate.day} ${tokH}:${String(tokM).padStart(2,'0')}`);
200
+ ```
201
+
202
+ ### Computing the number of days between two dates
203
+
204
+ Since Julian Day is a continuous count, subtraction gives you the exact number of days between any two dates.
205
+
206
+ ```typescript
207
+ import { SwissEph } from '../index';
208
+
209
+ const jd1 = SwissEph.julianDay(2000, 1, 1, 0);
210
+ const jd2 = SwissEph.julianDay(2025, 6, 15, 0);
211
+
212
+ const days = jd2 - jd1;
213
+ const years = days / 365.25;
214
+ console.log(`Days between 2000-01-01 and 2025-06-15: ${days.toFixed(1)}`);
215
+ console.log(`Approximately ${years.toFixed(2)} years`);
216
+
217
+ // How many days since the Unix epoch? (January 1, 1970 00:00 UTC)
218
+ const unixEpoch = SwissEph.julianDay(1970, 1, 1, 0);
219
+ const now = SwissEph.julianDay(2025, 6, 15, 12);
220
+ console.log(`\nDays since Unix epoch: ${(now - unixEpoch).toFixed(1)}`);
221
+ ```
222
+
223
+ ### Using utcToJd with seconds precision
224
+
225
+ The `utcToJd()` method accepts seconds as a floating-point number, giving you sub-second precision.
226
+
227
+ ```typescript
228
+ import { SwissEph } from '../index';
229
+
230
+ // A precise event: 2025-03-20 09:01:25.432 UTC
231
+ const result = SwissEph.utcToJd(2025, 3, 20, 9, 1, 25.432);
232
+ console.log(`JD (ET): ${result.tjdEt.toFixed(8)}`);
233
+ console.log(`JD (UT): ${result.tjdUt.toFixed(8)}`);
234
+
235
+ // Verify by converting back
236
+ const back = SwissEph.jdUtToUtc(result.tjdUt);
237
+ console.log(`\nVerification:`);
238
+ console.log(` ${back.year}-${back.month}-${back.day} ${back.hour}:${back.minute}:${back.second.toFixed(3)}`);
239
+ ```
240
+
241
+ ---
242
+
243
+ ## Deep Explanation
244
+
245
+ ### Julian Day origin and numbering
246
+
247
+ The Julian Day count begins at **JD 0.0 = January 1, 4713 BC (Julian calendar) at 12:00 noon** (Greenwich Mean Time). This seemingly arbitrary starting point was chosen by Joseph Scaliger because it is the start of the current cycle of three combined chronological cycles (the 28-year solar cycle, the 19-year Metonic cycle, and the 15-year indiction cycle). By starting so far in the past, all recorded historical dates have positive Julian Day numbers.
248
+
249
+ Key Julian Day values:
250
+
251
+ | JD | Date | Significance |
252
+ |----|------|-------------|
253
+ | 0.0 | Jan 1, 4713 BC noon | JD epoch |
254
+ | 2299160.5 | Oct 15, 1582 midnight | Start of Gregorian calendar |
255
+ | 2415020.0 | Jan 0.5, 1900 | Origin of "Julian Date" in some older systems |
256
+ | 2440587.5 | Jan 1, 1970 midnight | Unix epoch |
257
+ | 2451545.0 | Jan 1, 2000 noon | J2000.0 epoch |
258
+
259
+ ### The noon convention
260
+
261
+ Julian Day numbers change at **noon UT**, not at midnight. This was designed for the convenience of astronomers, who typically observe at night -- a single Julian Day number covers an entire night of observations without the day changing in the middle.
262
+
263
+ This means:
264
+ - JD 2451545.0 = January 1, 2000 at **12:00 noon** UT
265
+ - JD 2451545.5 = January 2, 2000 at **00:00 midnight** UT
266
+ - JD 2451544.75 = January 1, 2000 at **06:00 AM** UT
267
+
268
+ The fractional part of the JD encodes the time of day: .0 = noon, .25 = 6 PM, .5 = midnight, .75 = 6 AM.
269
+
270
+ ### Modified Julian Day
271
+
272
+ The **Modified Julian Day** (MJD) is a commonly used variant:
273
+
274
+ ```
275
+ MJD = JD - 2400000.5
276
+ ```
277
+
278
+ The MJD starts at midnight (not noon) on November 17, 1858. It is used by many modern astronomical data systems because the numbers are smaller and more convenient. The Swiss Ephemeris uses regular JD internally, but you can easily convert.
279
+
280
+ ### ET vs UT: why there are two time scales
281
+
282
+ **Universal Time (UT)** is based on the Earth's rotation. It is the time you read on a clock (after adjusting for time zones). However, the Earth's rotation is not perfectly uniform -- it gradually slows down due to tidal friction, and it has irregular fluctuations.
283
+
284
+ **Ephemeris Time (ET)**, also called **Terrestrial Time (TT)**, is a uniform time scale defined by atomic clocks. It ticks at a perfectly constant rate. This is the time scale used internally by the planetary ephemeris, because the laws of physics (and thus planetary orbits) follow uniform time.
285
+
286
+ The difference between ET and UT is called **delta-T**:
287
+
288
+ ```
289
+ ET = UT + delta-T
290
+ ```
291
+
292
+ In 2025, delta-T is approximately 69.2 seconds. This means ET is about 69 seconds ahead of UT. For ancient dates, the difference is much larger (hours or even days) because it has accumulated over centuries.
293
+
294
+ ### Why utcToJd returns both ET and UT
295
+
296
+ The `utcToJd()` method returns two Julian Day values:
297
+
298
+ - `tjdEt`: for use with functions that expect Ephemeris Time (if you created the SwissEph instance with `timeMode: 'et'`)
299
+ - `tjdUt`: for use with functions that expect Universal Time (the default mode)
300
+
301
+ In most cases, you will use `tjdUt` (since the default time mode is UT). The `tjdEt` value is useful if you need to pass time to the lower-level engine directly.
302
+
303
+ ### The fractional hour convention
304
+
305
+ The `julianDay()` function takes the hour as a single floating-point number:
306
+
307
+ | Hour value | Actual time |
308
+ |-----------|-------------|
309
+ | 0 | 00:00 (midnight) |
310
+ | 6.5 | 06:30 |
311
+ | 12 | 12:00 (noon) |
312
+ | 18.75 | 18:45 |
313
+ | 23.999 | 23:59:56.4 |
314
+
315
+ To convert hours, minutes, seconds to fractional hours:
316
+ ```typescript
317
+ const fractionalHour = hours + minutes / 60 + seconds / 3600;
318
+ ```
319
+
320
+ For more precision (separate hour, minute, second with floating-point seconds), use `utcToJd()` instead.
321
+
322
+ ### Gregorian vs Julian calendar details
323
+
324
+ The Julian calendar, introduced by Julius Caesar in 46 BC, has a simple leap year rule: every year divisible by 4 is a leap year. This gives an average year length of 365.25 days, which is about 11 minutes and 14 seconds too long compared to the actual solar year.
325
+
326
+ Over centuries, this error accumulated. By 1582, the calendar was about 10 days out of sync with the seasons. Pope Gregory XIII reformed the calendar by:
327
+ 1. Skipping 10 days (October 4 was followed by October 15, 1582)
328
+ 2. Changing the leap year rule: century years (1700, 1800, 1900) are NOT leap years, unless they are divisible by 400 (so 2000 WAS a leap year)
329
+
330
+ This gives an average year of 365.2425 days -- much closer to the solar year.
331
+
332
+ **When to use which calendar**:
333
+ - Dates after October 15, 1582 in Catholic countries: `SE_GREG_CAL`
334
+ - Dates after 1752 in Britain and its colonies: `SE_GREG_CAL`
335
+ - Dates before the local adoption of the Gregorian calendar: `SE_JUL_CAL`
336
+ - When in doubt for modern dates: `SE_GREG_CAL` (the default)
337
+
338
+ ### Astronomical year numbering
339
+
340
+ The Swiss Ephemeris uses **astronomical year numbering**, where:
341
+ - 1 AD = year 1
342
+ - 1 BC = year 0 (not year -1)
343
+ - 2 BC = year -1
344
+ - 3 BC = year -2
345
+ - etc.
346
+
347
+ This differs from the historical convention, which has no year 0. So when computing dates for "490 BC," pass -489 as the year.
348
+
349
+ ### Common epochs
350
+
351
+ | Epoch | JD | Description |
352
+ |-------|------|-------------|
353
+ | J2000.0 | 2451545.0 | January 1, 2000 at 12:00 TT. The standard reference epoch for modern astronomy. Most star catalogs and coordinate systems are defined relative to this epoch. |
354
+ | B1950.0 | 2433282.4235 | January 0.923, 1950 (Besselian year). An older reference epoch still found in some older catalogs. |
355
+ | J1900.0 | 2415020.0 | January 0.5, 1900. Used in some older ephemeris systems. |
356
+
357
+ ### Summary of static methods
358
+
359
+ | Method | Input | Output |
360
+ |--------|-------|--------|
361
+ | `SwissEph.julianDay(y, m, d, h?, gregflag?)` | Calendar date + fractional hour | Julian Day number |
362
+ | `SwissEph.fromJulianDay(jd, gregflag?)` | Julian Day number | `{ year, month, day, hour }` |
363
+ | `SwissEph.utcToJd(y, m, d, h, min, sec, gregflag?)` | Full UTC date/time | `{ tjdEt, tjdUt }` |
364
+ | `SwissEph.jdToUtc(jdEt, gregflag?)` | JD in ET | `{ year, month, day, hour, minute, second }` |
365
+ | `SwissEph.jdUtToUtc(jdUt, gregflag?)` | JD in UT | `{ year, month, day, hour, minute, second }` |
366
+ | `SwissEph.dayOfWeek(jd)` | Julian Day number | 0 (Mon) through 6 (Sun) |
367
+
368
+ All methods are **static** -- they are called on the class itself (`SwissEph.julianDay(...)`) and do not require creating an instance.
@@ -0,0 +1,258 @@
1
+ # Delta-T
2
+
3
+ **Delta-T** (written as the greek symbol, also known as the "delta-T correction") is the difference between two time scales: **Terrestrial Time (TT)** and **Universal Time (UT)**. It answers a deceptively simple question: how far has Earth's rotation drifted from a perfectly uniform clock?
4
+
5
+ - **Terrestrial Time (TT)** (formerly called Ephemeris Time) ticks at a perfectly uniform rate, defined by atomic clocks. It is the time scale used internally by the Swiss Ephemeris for all planetary calculations.
6
+ - **Universal Time (UT)** is based on the actual rotation of the Earth -- one UT day is one full rotation of the Earth relative to the mean Sun. Because the Earth's rotation is irregular (it is gradually slowing down due to tidal friction from the Moon, and also fluctuates unpredictably), UT days are not all exactly the same length.
7
+
8
+ **Delta-T = TT - UT**. When Delta-T is positive (as it is today), Terrestrial Time is ahead of Universal Time -- meaning the Earth has rotated slightly less than a perfectly uniform clock would predict.
9
+
10
+ Why does this matter? If you want to compute where the planets were at a given clock time (UT), the Swiss Ephemeris needs to know the corresponding TT to look up positions in its tables. The difference is small for modern dates (~69 seconds in 2024), but for ancient dates it can be hours, which dramatically affects where eclipses and other events are predicted to have occurred on Earth.
11
+
12
+ ---
13
+
14
+ ## Quick Example
15
+
16
+ ```typescript
17
+ import { SwissEph } from '../index';
18
+
19
+ const swe = new SwissEph();
20
+
21
+ // Get delta-T for J2000.0 (January 1, 2000 at 12:00 UT)
22
+ const jd = SwissEph.julianDay(2000, 1, 1, 12);
23
+ const dt = swe.deltaT(jd);
24
+
25
+ // The result is in fractions of a day -- multiply by 86400 for seconds
26
+ console.log(`Delta-T: ${(dt * 86400).toFixed(2)} seconds`);
27
+ // Delta-T: ~63.83 seconds
28
+
29
+ swe.close();
30
+ ```
31
+
32
+ ---
33
+
34
+ ## Detailed Examples
35
+
36
+ ### Delta-T at different historical epochs
37
+
38
+ Delta-T varies dramatically across history. In ancient times, the accumulated drift of Earth's rotation amounts to hours. In the modern era, it is tens of seconds.
39
+
40
+ ```typescript
41
+ import { SwissEph } from '../index';
42
+
43
+ const swe = new SwissEph();
44
+
45
+ const dates = [
46
+ { year: -500, label: '500 BCE' },
47
+ { year: 0, label: '1 BCE / 1 CE' },
48
+ { year: 500, label: '500 CE' },
49
+ { year: 1000, label: '1000 CE' },
50
+ { year: 1500, label: '1500 CE' },
51
+ { year: 1700, label: '1700 CE' },
52
+ { year: 1800, label: '1800 CE' },
53
+ { year: 1900, label: '1900 CE' },
54
+ { year: 1950, label: '1950 CE' },
55
+ { year: 2000, label: '2000 CE' },
56
+ { year: 2024, label: '2024 CE' },
57
+ ];
58
+
59
+ console.log('Epoch Delta-T (seconds) Delta-T (hours)');
60
+ console.log('------ ----------------- ---------------');
61
+
62
+ for (const d of dates) {
63
+ const jd = SwissEph.julianDay(d.year, 7, 1, 12);
64
+ const dt = swe.deltaT(jd);
65
+ const seconds = dt * 86400;
66
+ const hours = seconds / 3600;
67
+ console.log(
68
+ `${d.label.padEnd(17)}` +
69
+ `${seconds.toFixed(1).padStart(10)} s` +
70
+ `${hours.toFixed(3).padStart(16)} h`
71
+ );
72
+ }
73
+
74
+ swe.close();
75
+ ```
76
+
77
+ Expected approximate output:
78
+
79
+ | Epoch | Delta-T (seconds) | Delta-T (hours) |
80
+ |-----------|--------------------|-----------------|
81
+ | 500 BCE | ~17,190 s | ~4.8 h |
82
+ | 1 BCE | ~10,580 s | ~2.9 h |
83
+ | 500 CE | ~5,710 s | ~1.6 h |
84
+ | 1000 CE | ~1,570 s | ~0.4 h |
85
+ | 1500 CE | ~141 s | ~0.04 h |
86
+ | 1700 CE | ~9 s | ~0.002 h |
87
+ | 1800 CE | ~14 s | ~0.004 h |
88
+ | 1900 CE | ~-3 s | ~-0.001 h |
89
+ | 1950 CE | ~29 s | ~0.008 h |
90
+ | 2000 CE | ~64 s | ~0.018 h |
91
+ | 2024 CE | ~69 s | ~0.019 h |
92
+
93
+ Note how Delta-T was actually slightly negative around 1900, meaning Earth was slightly ahead of the uniform clock at that time. The overall trend is increasing due to the gradual slowing of Earth's rotation.
94
+
95
+ ### Converting between UT and ET manually
96
+
97
+ In most cases the library handles this automatically (if you use `timeMode: 'ut'`, every call internally adds Delta-T). But if you need to convert manually:
98
+
99
+ ```typescript
100
+ import { SwissEph } from '../index';
101
+
102
+ const swe = new SwissEph();
103
+
104
+ // Given a UT date: April 8, 2024 at 18:00 UT
105
+ const jdUt = SwissEph.julianDay(2024, 4, 8, 18.0);
106
+
107
+ // Get Delta-T for this date
108
+ const dt = swe.deltaT(jdUt);
109
+
110
+ // Convert to Ephemeris Time (TT)
111
+ const jdEt = jdUt + dt;
112
+
113
+ console.log(`JD (UT): ${jdUt.toFixed(6)}`);
114
+ console.log(`Delta-T: ${(dt * 86400).toFixed(2)} seconds`);
115
+ console.log(`JD (ET): ${jdEt.toFixed(6)}`);
116
+ console.log(`Difference: ${(dt * 86400).toFixed(2)} seconds = ${(dt * 86400 / 60).toFixed(4)} minutes`);
117
+
118
+ swe.close();
119
+ ```
120
+
121
+ ### Setting a user-defined Delta-T
122
+
123
+ For research purposes you may want to override the built-in Delta-T model with a specific value. For example, when testing historical eclipse computations with a known Delta-T estimate:
124
+
125
+ ```typescript
126
+ import { SwissEph } from '../index';
127
+ import { SE_SUN } from '../../constants';
128
+
129
+ const swe = new SwissEph();
130
+
131
+ const jd = SwissEph.julianDay(-600, 5, 28, 12); // 601 BCE
132
+
133
+ // Check the default delta-T
134
+ const dtDefault = swe.deltaT(jd);
135
+ console.log(`Default Delta-T: ${(dtDefault * 86400).toFixed(1)} seconds`);
136
+
137
+ // Override with a custom value (in fractions of a day)
138
+ // For example, set Delta-T to exactly 18,000 seconds (5 hours)
139
+ swe.setDeltaTUserDefined(18000 / 86400);
140
+
141
+ const dtCustom = swe.deltaT(jd);
142
+ console.log(`Custom Delta-T: ${(dtCustom * 86400).toFixed(1)} seconds`);
143
+
144
+ // All subsequent UT-based calculations will use this value
145
+ const sun = swe.calc(jd, SE_SUN);
146
+ console.log(`Sun longitude with custom Delta-T: ${sun.longitude.toFixed(4)} deg`);
147
+
148
+ swe.close();
149
+ ```
150
+
151
+ ### Observing Delta-T growth over recent decades
152
+
153
+ ```typescript
154
+ import { SwissEph } from '../index';
155
+
156
+ const swe = new SwissEph();
157
+
158
+ console.log('Year Delta-T (s) Growth (s/yr)');
159
+ console.log('---- ----------- -------------');
160
+
161
+ let prevDt = 0;
162
+ for (let year = 1970; year <= 2024; year += 2) {
163
+ const jd = SwissEph.julianDay(year, 1, 1, 0);
164
+ const dt = swe.deltaT(jd) * 86400;
165
+ const growth = prevDt ? (dt - prevDt) / 2 : 0;
166
+ console.log(
167
+ `${year} ${dt.toFixed(2).padStart(8)} s ` +
168
+ `${prevDt ? growth.toFixed(3).padStart(8) : ' --'} s/yr`
169
+ );
170
+ prevDt = dt;
171
+ }
172
+
173
+ swe.close();
174
+ ```
175
+
176
+ ---
177
+
178
+ ## Deep Explanation
179
+
180
+ ### Why Earth's rotation is slowing down
181
+
182
+ The primary cause is **tidal friction**. The Moon raises tides in the oceans (and to a lesser extent in the solid Earth). As the Earth rotates, it drags these tidal bulges slightly ahead of the Earth-Moon line. The gravitational pull of the Moon on these bulges acts as a brake on Earth's rotation, slowing it down by about 2.3 milliseconds per century. As a consequence, the Moon is also slowly spiraling outward from Earth, gaining orbital energy at the expense of Earth's rotational energy. The Moon recedes by about 3.8 cm per year.
183
+
184
+ Over centuries, this tiny daily slowdown accumulates into a significant offset. After 1000 years of 2 ms/century deceleration, the accumulated drift is roughly:
185
+
186
+ ```
187
+ 0.5 * (deceleration) * (time)^2 = 0.5 * (2.3 ms/century) * (10 centuries)^2 ~ 115 seconds per century squared
188
+ ```
189
+
190
+ This is why Delta-T grows roughly quadratically with time -- the values for ancient dates are thousands of seconds.
191
+
192
+ ### Unpredictable fluctuations
193
+
194
+ Besides the smooth tidal deceleration, Earth's rotation has irregular fluctuations on timescales from days to decades. These are caused by:
195
+
196
+ - **Core-mantle coupling**: Fluid motions in Earth's liquid outer core transfer angular momentum to the solid mantle
197
+ - **Post-glacial rebound**: The mantle is still rebounding from ice-age glaciers, changing Earth's moment of inertia
198
+ - **Atmospheric and oceanic circulation**: Seasonal and weather-related angular momentum exchanges
199
+ - **Earthquakes**: Large events can measurably change Earth's moment of inertia (the 2004 Sumatra earthquake shortened the day by ~2.7 microseconds)
200
+
201
+ Because of these unpredictable components, Delta-T cannot be precisely predicted for the future. Extrapolations more than 10-20 years ahead diverge from actual measurements by several seconds.
202
+
203
+ ### Historical constraints: ancient eclipse records
204
+
205
+ For dates before the telescopic era (pre-1600), Delta-T is estimated primarily from historical records of eclipses. Ancient Babylonian clay tablets record solar and lunar eclipses with enough detail to constrain when they occurred and, crucially, where they were visible. If a total solar eclipse was observed in Babylon on a known date, we can compute the eclipse geometry and figure out what Delta-T must have been to place the eclipse path over Babylon. Chinese and Arabic records provide additional constraints. The uncertainty in Delta-T for ancient dates is still large (hundreds of seconds for dates before 500 BCE) but these eclipse records are the best evidence we have.
206
+
207
+ ### The Delta-T models in Swiss Ephemeris
208
+
209
+ The Swiss Ephemeris uses a composite Delta-T model assembled from several sources:
210
+
211
+ 1. **Observed values (1955-present)**: Directly measured values from the International Earth Rotation and Reference Systems Service (IERS), the most accurate data available
212
+ 2. **Historical tables (1620-1955)**: Based on telescope-era observations, primarily from Stephenson, Morrison, and Hohenkerk (2016)
213
+ 3. **Parabolic extrapolation (before 1620)**: Based on Stephenson, Morrison, and Hohenkerk's analysis of historical eclipse records, using the tidal deceleration rate to extrapolate further back
214
+ 4. **Future extrapolation (after latest observed values)**: A parabolic projection based on the current rate of change, with growing uncertainty
215
+
216
+ The `flags` parameter can select different Delta-T models, though the default (`-1`) uses the built-in composite model which is appropriate for nearly all use cases.
217
+
218
+ ### Leap seconds and Delta-T
219
+
220
+ Since 1972, **leap seconds** have been periodically added to UTC (Coordinated Universal Time) to keep it within 0.9 seconds of UT1 (a refined version of UT). This means UTC effectively tracks UT1 in a stepwise fashion. Delta-T, however, measures the smooth difference between TT and UT1, independent of leap seconds. The relationship is:
221
+
222
+ ```
223
+ Delta-T = 32.184 s + (TAI - UTC) - (UT1 - UTC)
224
+ ```
225
+
226
+ where TAI (International Atomic Time) and TT differ by a constant 32.184 seconds, and (TAI - UTC) is the cumulative leap second count.
227
+
228
+ As of 2024, 27 leap seconds have been added since 1972, and the last one was in December 2016. Earth's rotation has recently been slightly speeding up (for reasons not fully understood), leading to discussions of potentially needing a "negative leap second" -- an unprecedented event that has never occurred.
229
+
230
+ ### Why Delta-T matters for practical calculations
231
+
232
+ For modern dates (say, 1900-2100), Delta-T is at most about 1-2 minutes. Since planets move relatively slowly, a 1-minute error in time translates to a tiny fraction of a degree in planetary positions -- negligible for most purposes.
233
+
234
+ But for ancient dates, the situation is very different:
235
+
236
+ | Date | Delta-T | Moon error at horizon |
237
+ |------------|------------|-----------------------|
238
+ | 2024 CE | ~69 s | ~0.03 deg |
239
+ | 1000 CE | ~1,570 s | ~0.7 deg |
240
+ | 500 BCE | ~17,190 s | ~7.9 deg |
241
+ | 3000 BCE | ~58,000 s | ~27 deg |
242
+
243
+ The Moon moves about 0.5 degrees per minute, so an uncertainty of even 1000 seconds (17 minutes) in Delta-T shifts the predicted Moon position by about 8 degrees. This is larger than the Moon's angular diameter and enough to completely change whether a solar eclipse is visible from a given location. This is why historical eclipse computations always require careful attention to Delta-T.
244
+
245
+ ### The result is a fraction of a day
246
+
247
+ The `deltaT()` method returns its result as a **fraction of a Julian day**, not in seconds. This matches the convention used internally by the Swiss Ephemeris where time differences are in day fractions. To convert:
248
+
249
+ ```typescript
250
+ const dtDays = swe.deltaT(jd); // fraction of a day
251
+ const dtSeconds = dtDays * 86400; // seconds
252
+ const dtMinutes = dtDays * 1440; // minutes
253
+ const dtHours = dtDays * 24; // hours
254
+ ```
255
+
256
+ ### The flags parameter
257
+
258
+ The optional `flags` parameter to `deltaT()` defaults to `-1`, which selects the default built-in model. You should rarely need to change this. The flags value matches the ephemeris flag constants (`SEFLG_MOSEPH`, `SEFLG_SWIEPH`, `SEFLG_JPLEPH`), and different ephemeris modes may use slightly different tidal acceleration values which feed into the Delta-T model. In practice, the differences between models are negligible for dates within a few thousand years of the present.