-
Notifications
You must be signed in to change notification settings - Fork 10
/
houses.js
58 lines (54 loc) · 1.36 KB
/
houses.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
const swisseph = require("swisseph");
const { getValidatedBirthDetails } = require("jyotish").utils.birthDetails;
/**
*
* @typedef {Object} BirthDetails
* @property {String} dateString - Format: YYYY-MM-DD
* @property {String} timeString - Format: HH:mm:ss
* @property {Number} lat - Latitude
* @property {Number} lng - Longitude
* @property {Number} timezone - Timezone in hours. Eg: 5.5
*/
/**
*
* @param {BirthDetails} birthDetails
*/
const convertTime = (birthDetails) => {
let utc = swisseph.swe_utc_time_zone(
birthDetails.year,
birthDetails.month,
birthDetails.date,
birthDetails.hour,
birthDetails.min,
birthDetails.sec,
birthDetails.timezone
);
let retval = swisseph.swe_utc_to_jd(
utc.year,
utc.month,
utc.day,
utc.hour,
utc.minute,
utc.second,
swisseph.SE_GREG_CAL
);
let et = retval.julianDayET;
tt = retval.julianDayUT;
return { utc, retval, et, tt };
};
/**
*
* @param {BirthDetails} birthDetails birth details
* @param {String} house_type House System. Default: "Whole Sign" = "W"
*/
function calculateHouses(birthDetails, house_type = "W") {
const { tt } = convertTime(getValidatedBirthDetails(birthDetails));
return swisseph.swe_houses_ex(
tt,
swisseph.SEFLG_SIDEREAL,
birthDetails.lat,
birthDetails.lng,
house_type
);
}
module.exports = { calculateHouses };