@swisseph/node 1.0.6 → 1.1.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.
- package/README.md +28 -7
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +35 -0
- package/package.json +1 -1
- package/prebuilds/darwin-arm64/swisseph.node +0 -0
- package/prebuilds/win32-x64/swisseph.node +0 -0
package/README.md
CHANGED
|
@@ -42,7 +42,7 @@ npm install --global windows-build-tools
|
|
|
42
42
|
|
|
43
43
|
```typescript
|
|
44
44
|
import {
|
|
45
|
-
|
|
45
|
+
dateToJulianDay,
|
|
46
46
|
calculatePosition,
|
|
47
47
|
calculateHouses,
|
|
48
48
|
Planet,
|
|
@@ -51,8 +51,9 @@ import {
|
|
|
51
51
|
|
|
52
52
|
// No setup required! Ephemeris files are bundled and auto-loaded.
|
|
53
53
|
|
|
54
|
-
// Calculate planetary position
|
|
55
|
-
const
|
|
54
|
+
// Calculate planetary position using Date object
|
|
55
|
+
const date = new Date('2007-03-03T00:00:00Z');
|
|
56
|
+
const jd = dateToJulianDay(date);
|
|
56
57
|
const sun = calculatePosition(jd, Planet.Sun);
|
|
57
58
|
console.log(`Sun: ${sun.longitude}°`);
|
|
58
59
|
|
|
@@ -67,10 +68,28 @@ console.log(`MC: ${houses.mc}°`);
|
|
|
67
68
|
### Date & Time
|
|
68
69
|
|
|
69
70
|
```typescript
|
|
71
|
+
// Convert JavaScript Date to Julian day (recommended)
|
|
72
|
+
dateToJulianDay(date, calendarType?)
|
|
73
|
+
|
|
74
|
+
// Convert date components to Julian day
|
|
70
75
|
julianDay(year, month, day, hour?, calendarType?)
|
|
76
|
+
|
|
77
|
+
// Convert Julian day back to date
|
|
71
78
|
julianDayToDate(jd, calendarType?)
|
|
72
79
|
```
|
|
73
80
|
|
|
81
|
+
**Examples:**
|
|
82
|
+
```typescript
|
|
83
|
+
// Using Date object (easiest)
|
|
84
|
+
const jd = dateToJulianDay(new Date('1990-05-15T14:30:00Z'));
|
|
85
|
+
|
|
86
|
+
// Using date components
|
|
87
|
+
const jd2 = julianDay(1990, 5, 15, 14.5); // Same result
|
|
88
|
+
|
|
89
|
+
// Current time
|
|
90
|
+
const now = dateToJulianDay(new Date());
|
|
91
|
+
```
|
|
92
|
+
|
|
74
93
|
### Planetary Positions
|
|
75
94
|
|
|
76
95
|
```typescript
|
|
@@ -147,7 +166,7 @@ import {
|
|
|
147
166
|
|
|
148
167
|
```typescript
|
|
149
168
|
import {
|
|
150
|
-
|
|
169
|
+
dateToJulianDay,
|
|
151
170
|
calculatePosition,
|
|
152
171
|
calculateHouses,
|
|
153
172
|
Planet,
|
|
@@ -156,7 +175,8 @@ import {
|
|
|
156
175
|
} from '@swisseph/node';
|
|
157
176
|
|
|
158
177
|
// Birth: May 15, 1990, 14:30 UTC, New York (40.7128°N, 74.0060°W)
|
|
159
|
-
const
|
|
178
|
+
const birthDate = new Date('1990-05-15T14:30:00Z');
|
|
179
|
+
const jd = dateToJulianDay(birthDate);
|
|
160
180
|
|
|
161
181
|
// Calculate all planet positions
|
|
162
182
|
const planets = [
|
|
@@ -220,9 +240,10 @@ close();
|
|
|
220
240
|
### Planetary Aspects
|
|
221
241
|
|
|
222
242
|
```typescript
|
|
223
|
-
import {
|
|
243
|
+
import { dateToJulianDay, calculatePosition, Planet, close } from '@swisseph/node';
|
|
224
244
|
|
|
225
|
-
|
|
245
|
+
// Calculate for current time
|
|
246
|
+
const jd = dateToJulianDay(new Date());
|
|
226
247
|
|
|
227
248
|
// Calculate positions
|
|
228
249
|
const sun = calculatePosition(jd, Planet.Sun);
|
package/dist/index.d.ts
CHANGED
|
@@ -42,6 +42,29 @@ export declare function setEphemerisPath(path?: string | null): void;
|
|
|
42
42
|
* console.log(jdWithTime); // 2454163.104166667
|
|
43
43
|
*/
|
|
44
44
|
export declare function julianDay(year: number, month: number, day: number, hour?: number, calendarType?: CalendarType): number;
|
|
45
|
+
/**
|
|
46
|
+
* Calculate Julian day number from a JavaScript Date object
|
|
47
|
+
*
|
|
48
|
+
* Convenience function that converts a JavaScript Date to Julian day number.
|
|
49
|
+
* The Date is interpreted as UTC.
|
|
50
|
+
*
|
|
51
|
+
* @param date - JavaScript Date object (interpreted as UTC)
|
|
52
|
+
* @param calendarType - Calendar system (default: Gregorian)
|
|
53
|
+
* @returns Julian day number
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* // From Date object
|
|
57
|
+
* const date = new Date('1990-05-15T14:30:00Z');
|
|
58
|
+
* const jd = dateToJulianDay(date);
|
|
59
|
+
*
|
|
60
|
+
* // From timestamp
|
|
61
|
+
* const now = new Date();
|
|
62
|
+
* const jdNow = dateToJulianDay(now);
|
|
63
|
+
*
|
|
64
|
+
* // Equivalent to julianDay(1990, 5, 15, 14.5)
|
|
65
|
+
* const jd2 = dateToJulianDay(new Date(Date.UTC(1990, 4, 15, 14, 30)));
|
|
66
|
+
*/
|
|
67
|
+
export declare function dateToJulianDay(date: Date, calendarType?: CalendarType): number;
|
|
45
68
|
/**
|
|
46
69
|
* Convert Julian day number to calendar date
|
|
47
70
|
*
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,YAAY,EAEZ,aAAa,EACb,WAAW,EAEX,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,SAAS,EACT,YAAY,EACZ,YAAY,EAEZ,gBAAgB,EAQjB,MAAM,gBAAgB,CAAC;AAkCxB;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAU3D;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,GAAG,EAA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AAc,EAAE,MAAM,EACtB,KAAK,GAAE,oBAAqD,EAC5D,WAAW,GAAE,oBAAwB,EACrC,QAAQ,GAAE,OAAe,GACxB,YAAY,CAwBd;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAEhE;AAED;;;;;;;;;GASG;AACH,wBAAgB,KAAK,IAAI,IAAI,CAE5B;AAGD,cAAc,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -44,6 +44,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
44
44
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
45
|
exports.setEphemerisPath = setEphemerisPath;
|
|
46
46
|
exports.julianDay = julianDay;
|
|
47
|
+
exports.dateToJulianDay = dateToJulianDay;
|
|
47
48
|
exports.julianDayToDate = julianDayToDate;
|
|
48
49
|
exports.calculatePosition = calculatePosition;
|
|
49
50
|
exports.calculateHouses = calculateHouses;
|
|
@@ -128,6 +129,40 @@ function setEphemerisPath(path) {
|
|
|
128
129
|
function julianDay(year, month, day, hour = 0, calendarType = core_1.CalendarType.Gregorian) {
|
|
129
130
|
return binding.julday(year, month, day, hour, calendarType);
|
|
130
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* Calculate Julian day number from a JavaScript Date object
|
|
134
|
+
*
|
|
135
|
+
* Convenience function that converts a JavaScript Date to Julian day number.
|
|
136
|
+
* The Date is interpreted as UTC.
|
|
137
|
+
*
|
|
138
|
+
* @param date - JavaScript Date object (interpreted as UTC)
|
|
139
|
+
* @param calendarType - Calendar system (default: Gregorian)
|
|
140
|
+
* @returns Julian day number
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* // From Date object
|
|
144
|
+
* const date = new Date('1990-05-15T14:30:00Z');
|
|
145
|
+
* const jd = dateToJulianDay(date);
|
|
146
|
+
*
|
|
147
|
+
* // From timestamp
|
|
148
|
+
* const now = new Date();
|
|
149
|
+
* const jdNow = dateToJulianDay(now);
|
|
150
|
+
*
|
|
151
|
+
* // Equivalent to julianDay(1990, 5, 15, 14.5)
|
|
152
|
+
* const jd2 = dateToJulianDay(new Date(Date.UTC(1990, 4, 15, 14, 30)));
|
|
153
|
+
*/
|
|
154
|
+
function dateToJulianDay(date, calendarType = core_1.CalendarType.Gregorian) {
|
|
155
|
+
const year = date.getUTCFullYear();
|
|
156
|
+
const month = date.getUTCMonth() + 1; // JavaScript months are 0-indexed
|
|
157
|
+
const day = date.getUTCDate();
|
|
158
|
+
const hours = date.getUTCHours();
|
|
159
|
+
const minutes = date.getUTCMinutes();
|
|
160
|
+
const seconds = date.getUTCSeconds();
|
|
161
|
+
const milliseconds = date.getUTCMilliseconds();
|
|
162
|
+
// Convert to decimal hours
|
|
163
|
+
const decimalHours = hours + minutes / 60 + seconds / 3600 + milliseconds / 3600000;
|
|
164
|
+
return julianDay(year, month, day, decimalHours, calendarType);
|
|
165
|
+
}
|
|
131
166
|
/**
|
|
132
167
|
* Convert Julian day number to calendar date
|
|
133
168
|
*
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|