/vba/SwissEphemeris.vba

https://github.com/rplantiko/campanus · Visual Basic · 1249 lines · 1022 code · 168 blank · 59 comment · 0 complexity · 87af81a57e0cf5b807b4da7dbfe91e0a MD5 · raw file

  1. Attribute VB_Name = "SwissEphemeris"
  2. Option Explicit
  3. Private jd_ut_act As Double
  4. Private lat_act As Double
  5. Private lon_act As Double
  6. Private h(13) As Double
  7. Private ascmc(10) As Double
  8. Private ephe_path_set As Boolean
  9. Public Const Deg2Arc As Double = 1.74532925199433E-02
  10. Public Const Campanus As Long = 67 ' = ASCII-Code für "C"
  11. ' -------------------------------------------------------
  12. ' Declarations of the Swiss Ephemeris functions
  13. ' as VB functions (from http://www.astro.com/swisseph/swephprg.htm)
  14. ' -------------------------------------------------------
  15. Public Declare Function swe_azalt Lib "swedll32.dll" _
  16. Alias "_swe_azalt@40" ( _
  17. ByVal tjd_ut As Double, _
  18. ByVal calc_flag As Long, _
  19. ByRef geopos As Double, _
  20. ByVal atpress As Double, _
  21. ByVal attemp As Double, _
  22. ByRef xin As Double, _
  23. ByRef xaz As Double _
  24. ) As Long 'geopos must be the first of three array elements
  25. 'xin must be the first of two array elements
  26. 'xaz must be the first of three array elements
  27. Public Declare Function swe_azalt_rev Lib "swedll32.dll" _
  28. Alias "_swe_azalt_rev@24" ( _
  29. ByVal tjd_ut As Double, _
  30. ByVal calc_flag As Long, _
  31. ByRef geopos As Double, _
  32. ByRef xin As Double, _
  33. ByRef xout As Double _
  34. ) As Long 'geopos must be the first of three array elements
  35. 'xin must be the first of two array elements
  36. 'xout must be the first of three array elements
  37. Public Declare Function swe_calc Lib "swedll32.dll" _
  38. Alias "_swe_calc@24" ( _
  39. ByVal tjd As Double, _
  40. ByVal ipl As Long, _
  41. ByVal iflag As Long, _
  42. ByRef x As Double, _
  43. ByVal serr As String _
  44. ) As Long ' x must be first of six array elements
  45. ' serr must be able to hold 256 bytes
  46. Public Declare Function swe_calc_d Lib "swedll32.dll" _
  47. Alias "_swe_calc_d@20" ( _
  48. ByRef tjd As Double, _
  49. ByVal ipl As Long, _
  50. ByVal iflag As Long, _
  51. ByRef x As Double, _
  52. ByVal serr As String _
  53. ) As Long ' x must be first of six array elements
  54. ' serr must be able to hold 256 bytes
  55. Public Declare Function swe_calc_ut Lib "swedll32.dll" _
  56. Alias "_swe_calc_ut@24" ( _
  57. ByVal tjd_ut As Double, _
  58. ByVal ipl As Long, _
  59. ByVal iflag As Long, _
  60. ByRef x As Double, _
  61. ByVal serr As String _
  62. ) As Long ' x must be first of six array elements
  63. ' serr must be able to hold 256 bytes
  64. Public Declare Function swe_calc_ut_d Lib "swedll32.dll" _
  65. Alias "_swe_calc_ut_d@20" ( _
  66. ByRef tjd_ut As Double, _
  67. ByVal ipl As Long, _
  68. ByVal iflag As Long, _
  69. ByRef x As Double, _
  70. ByVal serr As String _
  71. ) As Long ' x must be first of six array elements
  72. ' serr must be able to hold 256 bytes
  73. Public Declare Function swe_close Lib "swedll32.dll" _
  74. Alias "_swe_close@0" ( _
  75. ) As Long
  76. Public Declare Function swe_close_d Lib "swedll32.dll" _
  77. Alias "_swe_close_d@4" ( _
  78. ByVal ivoid As Long _
  79. ) As Long ' argument ivoid is ignored
  80. Public Declare Sub swe_cotrans Lib "swedll32.dll" _
  81. Alias "_swe_cotrans@16" ( _
  82. ByRef xpo As Double, _
  83. ByRef xpn As Double, _
  84. ByVal eps As Double _
  85. )
  86. Public Declare Function swe_cotrans_d Lib "swedll32.dll" _
  87. Alias "_swe_cotrans_d@12" ( _
  88. ByRef xpo As Double, _
  89. ByRef xpn As Double, _
  90. ByRef eps As Double _
  91. ) As Long
  92. Public Declare Sub swe_cotrans_sp Lib "swedll32.dll" _
  93. Alias "_swe_cotrans_sp@16" ( _
  94. ByRef xpo As Double, _
  95. ByRef xpn As Double, _
  96. ByVal eps As Double _
  97. )
  98. Public Declare Function swe_cotrans_sp_d Lib "swedll32.dll" _
  99. Alias "_swe_cotrans_sp_d@12" ( _
  100. ByRef xpo As Double, _
  101. ByRef xpn As Double, _
  102. ByRef eps As Double _
  103. ) As Long
  104. Public Declare Sub swe_cs2degstr Lib "swedll32.dll" _
  105. Alias "_swe_cs2degstr@8" ( _
  106. ByVal t As Long, _
  107. ByVal s As String _
  108. )
  109. Public Declare Function swe_cs2degstr_d Lib "swedll32.dll" _
  110. Alias "_swe_cs2degstr_d@8" ( _
  111. ByVal t As Long, _
  112. ByVal s As String _
  113. ) As Long
  114. Public Declare Sub swe_cs2lonlatstr Lib "swedll32.dll" _
  115. Alias "_swe_cs2lonlatstr@16" ( _
  116. ByVal t As Long, _
  117. ByVal pchar As Byte, _
  118. ByVal mchar As Byte, _
  119. ByVal s As String _
  120. )
  121. Public Declare Function swe_cs2lonlatstr_d Lib "swedll32.dll" _
  122. Alias "_swe_cs2lonlatstr_d@16" ( _
  123. ByVal t As Long, _
  124. ByRef pchar As Byte, _
  125. ByRef mchar As Byte, _
  126. ByVal s As String _
  127. ) As Long
  128. Public Declare Sub swe_cs2timestr Lib "swedll32.dll" _
  129. Alias "_swe_cs2timestr@16" ( _
  130. ByVal t As Long, _
  131. ByVal sep As Long, _
  132. ByVal supzero As Long, _
  133. ByVal s As String _
  134. )
  135. Public Declare Function swe_cs2timestr_d Lib "swedll32.dll" _
  136. Alias "_swe_cs2timestr_d@16" ( _
  137. ByVal t As Long, _
  138. ByVal sep As Long, _
  139. ByVal supzero As Long, _
  140. ByVal s As String _
  141. ) As Long
  142. Public Declare Function swe_csnorm Lib "swedll32.dll" _
  143. Alias "_swe_csnorm@4" ( _
  144. ByVal p As Long _
  145. ) As Long
  146. Public Declare Function swe_csnorm_d Lib "swedll32.dll" _
  147. Alias "_swe_csnorm_d@4" ( _
  148. ByVal p As Long _
  149. ) As Long
  150. Public Declare Function swe_csroundsec Lib "swedll32.dll" _
  151. Alias "_swe_csroundsec@4" ( _
  152. ByVal p As Long _
  153. ) As Long
  154. Public Declare Function swe_csroundsec_d Lib "swedll32.dll" _
  155. Alias "_swe_csroundsec_d@4" ( _
  156. ByVal p As Long _
  157. ) As Long
  158. Public Declare Function swe_d2l Lib "swedll32.dll" _
  159. Alias "_swe_d2l@8" ( _
  160. ) As Long
  161. Public Declare Function swe_d2l_d Lib "swedll32.dll" _
  162. Alias "_swe_d2l_d@4" ( _
  163. ) As Long
  164. Public Declare Function swe_date_conversion Lib "swedll32.dll" _
  165. Alias "_swe_date_conversion@28" ( _
  166. ByVal year As Long, _
  167. ByVal month As Long, _
  168. ByVal day As Long, _
  169. ByVal utime As Double, _
  170. ByVal cal As Byte, _
  171. ByRef tjd As Double _
  172. ) As Long
  173. Public Declare Function swe_date_conversion_d Lib "swedll32.dll" _
  174. Alias "_swe_date_conversion_d@24" ( _
  175. ByVal year As Long, _
  176. ByVal month As Long, _
  177. ByVal day As Long, _
  178. ByRef utime As Double, _
  179. ByRef cal As Byte, _
  180. ByRef tjd As Double _
  181. ) As Long
  182. Public Declare Function swe_day_of_week Lib "swedll32.dll" _
  183. Alias "_swe_day_of_week@8" ( _
  184. ByVal jd As Double _
  185. ) As Long
  186. Public Declare Function swe_day_of_week_d Lib "swedll32.dll" _
  187. Alias "_swe_day_of_week_d@4" ( _
  188. ByRef jd As Double _
  189. ) As Long
  190. Public Declare Function swe_degnorm Lib "swedll32.dll" _
  191. Alias "_swe_degnorm@8" ( _
  192. ByVal jd As Double _
  193. ) As Double
  194. Public Declare Function swe_degnorm_d Lib "swedll32.dll" _
  195. Alias "_swe_degnorm_d@4" ( _
  196. ByRef jd As Double _
  197. ) As Long
  198. Public Declare Function swe_deltat Lib "swedll32.dll" _
  199. Alias "_swe_deltat@8" ( _
  200. ByVal jd As Double _
  201. ) As Double
  202. Public Declare Function swe_deltat_d Lib "swedll32.dll" _
  203. Alias "_swe_deltat_d@8" ( _
  204. ByRef jd As Double, _
  205. ByRef deltat As Double _
  206. ) As Long
  207. Public Declare Function swe_difcs2n Lib "swedll32.dll" _
  208. Alias "_swe_difcs2n@8" ( _
  209. ByVal p1 As Long, _
  210. ByVal p2 As Long _
  211. ) As Long
  212. Public Declare Function swe_difcs2n_d Lib "swedll32.dll" _
  213. Alias "_swe_difcs2n_d@8" ( _
  214. ByVal p1 As Long, _
  215. ByVal p2 As Long _
  216. ) As Long
  217. Public Declare Function swe_difcsn Lib "swedll32.dll" _
  218. Alias "_swe_difcsn@8" ( _
  219. ByVal p1 As Long, _
  220. ByVal p2 As Long _
  221. ) As Long
  222. Public Declare Function swe_difcsn_d Lib "swedll32.dll" _
  223. Alias "_swe_difcsn_d@8" ( _
  224. ByVal p1 As Long, _
  225. ByVal p2 As Long _
  226. ) As Long
  227. Public Declare Function swe_difdeg2n Lib "swedll32.dll" _
  228. Alias "_swe_difdeg2n@16" ( _
  229. ByVal p1 As Double, _
  230. ByVal p2 As Double _
  231. ) As Double
  232. Public Declare Function swe_difdeg2n_d Lib "swedll32.dll" _
  233. Alias "_swe_difdeg2n_d@12" ( _
  234. ByRef p1 As Double, _
  235. ByRef p2 As Double, _
  236. ByRef Diff As Double _
  237. ) As Long
  238. Public Declare Function swe_difdegn Lib "swedll32.dll" _
  239. Alias "_swe_difdegn@16" ( _
  240. ByVal p1 As Double, _
  241. ByVal p2 As Double _
  242. ) As Long
  243. Public Declare Function swe_difdegn_d Lib "swedll32.dll" _
  244. Alias "_swe_difdegn_d@12" ( _
  245. ByRef p1 As Double, _
  246. ByRef p2 As Double, _
  247. ByRef Diff As Double _
  248. ) As Long
  249. Public Declare Function swe_fixstar Lib "swedll32.dll" _
  250. Alias "_swe_fixstar@24" ( _
  251. ByVal star As String, _
  252. ByVal tjd As Double, _
  253. ByVal iflag As Long, _
  254. ByRef x As Double, _
  255. ByVal serr As String _
  256. ) As Long ' x must be first of six array elements
  257. ' serr must be able to hold 256 bytes
  258. ' star must be able to hold 40 bytes
  259. Public Declare Function swe_fixstar_d Lib "swedll32.dll" _
  260. Alias "_swe_fixstar_d@20" ( _
  261. ByVal star As String, _
  262. ByRef tjd As Double, _
  263. ByVal iflag As Long, _
  264. ByRef x As Double, _
  265. ByVal serr As String _
  266. ) As Long ' x must be first of six array elements
  267. ' serr must be able to hold 256 bytes
  268. ' star must be able to hold 40 bytes
  269. Public Declare Function swe_fixstar_ut Lib "swedll32.dll" _
  270. Alias "_swe_fixstar_ut@24" ( _
  271. ByVal star As String, _
  272. ByVal tjd_ut As Double, _
  273. ByVal iflag As Long, _
  274. ByRef x As Double, _
  275. ByVal serr As String _
  276. ) As Long ' x must be first of six array elements
  277. ' serr must be able to hold 256 bytes
  278. ' star must be able to hold 40 bytes
  279. Public Declare Function swe_fixstar_ut_d Lib "swedll32.dll" _
  280. Alias "_swe_fixstar_ut_d@20" ( _
  281. ByVal star As String, _
  282. ByRef tjd_ut As Double, _
  283. ByVal iflag As Long, _
  284. ByRef x As Double, _
  285. ByVal serr As String _
  286. ) As Long ' x must be first of six array elements
  287. ' serr must be able to hold 256 bytes
  288. ' star must be able to hold 40 bytes
  289. Public Declare Function swe_get_ayanamsa Lib "swedll32.dll" _
  290. Alias "_swe_get_ayanamsa@8" ( _
  291. ByVal tjd_et As Double _
  292. ) As Double
  293. Public Declare Function swe_get_ayanamsa_d Lib "swedll32.dll" _
  294. Alias "_swe_get_ayanamsa_d@8" ( _
  295. ByRef tjd_et As Double, _
  296. ByRef ayan As Double _
  297. ) As Long
  298. Public Declare Function swe_get_ayanamsa_ut Lib "swedll32.dll" _
  299. Alias "_swe_get_ayanamsa_ut@8" ( _
  300. ByVal tjd_ut As Double _
  301. ) As Double
  302. Public Declare Function swe_get_ayanamsa_ut_d Lib "swedll32.dll" _
  303. Alias "_swe_get_ayanamsa_ut_d@8" ( _
  304. ByRef tjd_ut As Double, _
  305. ByRef ayan As Double _
  306. ) As Long
  307. Public Declare Sub swe_get_planet_name Lib "swedll32.dll" _
  308. Alias "_swe_get_planet_name@8" ( _
  309. ByVal ipl As Long, _
  310. ByVal pname As String _
  311. )
  312. Public Declare Function swe_get_planet_name_d Lib "swedll32.dll" _
  313. Alias "_swe_get_planet_name_d@8" ( _
  314. ByVal ipl As Long, _
  315. ByVal pname As String _
  316. ) As Long
  317. Public Declare Function swe_get_tid_acc Lib "swedll32.dll" _
  318. Alias "_swe_get_tid_acc@0" ( _
  319. ) As Double
  320. Public Declare Function swe_get_tid_acc_d Lib "swedll32.dll" _
  321. Alias "_swe_get_tid_acc_d@4" ( _
  322. ByRef x As Double _
  323. ) As Long
  324. Public Declare Function swe_houses Lib "swedll32.dll" _
  325. Alias "_swe_houses@36" ( _
  326. ByVal tjd_ut As Double, _
  327. ByVal geolat As Double, _
  328. ByVal geolon As Double, _
  329. ByVal ihsy As Long, _
  330. ByRef hcusps As Double, _
  331. ByRef ascmc As Double _
  332. ) As Long ' hcusps must be first of 13 array elements
  333. ' ascmc must be first of 10 array elements
  334. Public Declare Function swe_houses_d Lib "swedll32.dll" _
  335. Alias "_swe_houses_d@24" ( _
  336. ByRef tjd_ut As Double, _
  337. ByRef geolat As Double, _
  338. ByRef geolon As Double, _
  339. ByVal ihsy As Long, _
  340. ByRef hcusps As Double, _
  341. ByRef ascmc As Double _
  342. ) As Long ' hcusps must be first of 13 array elements
  343. ' ascmc must be first of 10 array elements
  344. Public Declare Function swe_houses_ex Lib "swedll32.dll" _
  345. Alias "_swe_houses_ex@40" ( _
  346. ByVal tjd_ut As Double, _
  347. ByVal iflag As Long, _
  348. ByVal geolat As Double, _
  349. ByVal geolon As Double, _
  350. ByVal ihsy As Long, _
  351. ByRef hcusps As Double, _
  352. ByRef ascmc As Double _
  353. ) As Long ' hcusps must be first of 13 array elements
  354. ' ascmc must be first of 10 array elements
  355. Public Declare Function swe_houses_ex_d Lib "swedll32.dll" _
  356. Alias "_swe_houses_ex_d@28" ( _
  357. ByRef tjd_ut As Double, _
  358. ByVal iflag As Long, _
  359. ByRef geolat As Double, _
  360. ByRef geolon As Double, _
  361. ByVal ihsy As Long, _
  362. ByRef hcusps As Double, _
  363. ByRef ascmc As Double _
  364. ) As Long ' hcusps must be first of 13 array elements
  365. ' ascmc must be first of 10 array elements
  366. Public Declare Function swe_houses_armc Lib "swedll32.dll" _
  367. Alias "_swe_houses_armc@36" ( _
  368. ByVal armc As Double, _
  369. ByVal geolat As Double, _
  370. ByVal eps As Double, _
  371. ByVal ihsy As Long, _
  372. ByRef hcusps As Double, _
  373. ByRef ascmc As Double _
  374. ) As Long ' hcusps must be first of 13 array elements
  375. ' ascmc must be first of 10 array elements
  376. Public Declare Function swe_houses_armc_d Lib "swedll32.dll" _
  377. Alias "_swe_houses_armc_d@24" ( _
  378. ByRef armc As Double, _
  379. ByRef geolat As Double, _
  380. ByRef eps As Double, _
  381. ByVal ihsy As Long, _
  382. ByRef hcusps As Double, _
  383. ByRef ascmc As Double _
  384. ) As Long ' hcusps must be first of 13 array elements
  385. ' ascmc must be first of 10 array elements
  386. Public Declare Function swe_house_pos Lib "swedll32.dll" _
  387. Alias "_swe_house_pos@36" ( _
  388. ByVal armc As Double, _
  389. ByVal geolat As Double, _
  390. ByVal eps As Double, _
  391. ByVal ihsy As Long, _
  392. ByRef xpin As Double, _
  393. ByVal serr As String _
  394. ) As Double
  395. ' xpin must be first of 2 array elements
  396. Public Declare Function swe_house_pos_d Lib "swedll32.dll" _
  397. Alias "_swe_house_pos_d@28" ( _
  398. ByRef armc As Double, _
  399. ByRef geolat As Double, _
  400. ByRef eps As Double, _
  401. ByVal ihsy As Long, _
  402. ByRef xpin As Double, _
  403. ByRef hpos As Double, _
  404. ByVal serr As String _
  405. ) As Long
  406. ' xpin must be first of 2 array elements
  407. Public Declare Function swe_julday Lib "swedll32.dll" _
  408. Alias "_swe_julday@24" ( _
  409. ByVal year As Long, _
  410. ByVal month As Long, _
  411. ByVal day As Long, _
  412. ByVal hour As Double, _
  413. ByVal gregflg As Long _
  414. ) As Double
  415. Public Declare Function swe_julday_d Lib "swedll32.dll" _
  416. Alias "_swe_julday_d@24" ( _
  417. ByVal year As Long, _
  418. ByVal month As Long, _
  419. ByVal day As Long, _
  420. ByRef hour As Double, _
  421. ByVal gregflg As Long, _
  422. ByRef tjd As Double _
  423. ) As Long
  424. Public Declare Function swe_lun_eclipse_how Lib "swedll32.dll" _
  425. Alias "_swe_lun_eclipse_how@24" ( _
  426. ByVal tjd_ut As Double, _
  427. ByVal ifl As Long, _
  428. ByRef geopos As Double, _
  429. ByRef attr As Double, _
  430. ByVal serr As String _
  431. ) As Long
  432. Public Declare Function swe_lun_eclipse_how_d Lib "swedll32.dll" _
  433. Alias "_swe_lun_eclipse_how_d@20" ( _
  434. ByRef tjd_ut As Double, _
  435. ByVal ifl As Long, _
  436. ByRef geopos As Double, _
  437. ByRef attr As Double, _
  438. ByVal serr As String _
  439. ) As Long
  440. Public Declare Function swe_lun_eclipse_when Lib "swedll32.dll" _
  441. Alias "_swe_lun_eclipse_when@28" ( _
  442. ByVal tjd_start As Double, _
  443. ByVal ifl As Long, _
  444. ByVal ifltype As Long, _
  445. ByRef tret As Double, _
  446. ByVal backward As Long, _
  447. ByVal serr As String _
  448. ) As Long
  449. Public Declare Function swe_lun_eclipse_when_d Lib "swedll32.dll" _
  450. Alias "_swe_lun_eclipse_when_d@24" ( _
  451. ByRef tjd_start As Double, _
  452. ByVal ifl As Long, _
  453. ByVal ifltype As Long, _
  454. ByRef tret As Double, _
  455. ByVal backward As Long, _
  456. ByVal serr As String _
  457. ) As Long
  458. Public Declare Function swe_nod_aps Lib "swedll32.dll" _
  459. Alias "_swe_nod_aps@40" ( _
  460. ByVal tjd_et As Double, ByVal ipl As Long, _
  461. ByVal iflag As Long, ByVal method As Long, _
  462. ByRef xnasc As Double, ByRef xndsc As Double, _
  463. ByRef xperi As Double, ByRef xaphe As Double, _
  464. ByVal serr As String _
  465. ) As Long
  466. Public Declare Function swe_nod_aps_ut Lib "swedll32.dll" _
  467. Alias "_swe_nod_aps_ut@40" ( _
  468. ByVal tjd_ut As Double, ByVal ipl As Long, _
  469. ByVal iflag As Long, ByVal method As Long, _
  470. ByRef xnasc As Double, ByRef xndsc As Double, _
  471. ByRef xperi As Double, ByRef xaphe As Double, _
  472. ByVal serr As String _
  473. ) As Long
  474. Public Declare Function swe_pheno Lib "swedll32.dll" _
  475. Alias "_swe_pheno@24" ( _
  476. ByVal tjd As Double, _
  477. ByVal ipl As Long, _
  478. ByVal iflag As Long, _
  479. ByRef attr As Double, _
  480. ByVal serr As String _
  481. ) As Long
  482. Public Declare Function swe_pheno_ut Lib "swedll32.dll" _
  483. Alias "_swe_pheno_ut@24" ( _
  484. ByVal tjd As Double, _
  485. ByVal ipl As Long, _
  486. ByVal iflag As Long, _
  487. ByRef attr As Double, _
  488. ByVal serr As String _
  489. ) As Long
  490. Public Declare Function swe_pheno_d Lib "swedll32.dll" _
  491. Alias "_swe_pheno_d@20" ( _
  492. ByRef tjd As Double, _
  493. ByVal ipl As Long, _
  494. ByVal iflag As Long, _
  495. ByRef attr As Double, _
  496. ByVal serr As String _
  497. ) As Long
  498. Public Declare Function swe_pheno_ut_d Lib "swedll32.dll" _
  499. Alias "_swe_pheno_ut_d@20" ( _
  500. ByRef tjd As Double, _
  501. ByVal ipl As Long, _
  502. ByVal iflag As Long, _
  503. ByRef attr As Double, _
  504. ByVal serr As String _
  505. ) As Long
  506. Public Declare Function swe_refrac Lib "swedll32.dll" _
  507. Alias "_swe_refrac@28" ( _
  508. ByVal inalt As Double, _
  509. ByVal atpress As Double, _
  510. ByVal attemp As Double, _
  511. ByVal calc_flag As Long _
  512. ) As Double
  513. Public Declare Sub swe_revjul Lib "swedll32.dll" _
  514. Alias "_swe_revjul@28" ( _
  515. ByVal tjd As Double, _
  516. ByVal gregflg As Long, _
  517. ByRef year As Long, _
  518. ByRef month As Long, _
  519. ByRef day As Long, _
  520. ByRef hour As Double _
  521. )
  522. Public Declare Function swe_revjul_d Lib "swedll32.dll" _
  523. Alias "_swe_revjul_d@24" ( _
  524. ByRef tjd As Double, _
  525. ByVal gregflg As Long, _
  526. ByRef year As Long, _
  527. ByRef month As Long, _
  528. ByRef day As Long, _
  529. ByRef hour As Double _
  530. ) As Long
  531. Public Declare Function swe_rise_trans Lib "swedll32.dll" _
  532. Alias "_swe_rise_trans@52" ( _
  533. ByVal tjd_ut As Double, ByVal ipl As Long, _
  534. ByVal starname As String, ByVal epheflag As Long, _
  535. ByVal rsmi As Long, ByRef geopos As Double, _
  536. ByVal atpress As Double, ByVal attemp As Double, _
  537. ByRef tret As Double, ByVal serr As String _
  538. ) As Long
  539. Public Declare Sub swe_set_ephe_path Lib "swedll32.dll" _
  540. Alias "_swe_set_ephe_path@4" ( _
  541. ByVal path As String _
  542. )
  543. Public Declare Function swe_set_ephe_path_d Lib "swedll32.dll" _
  544. Alias "_swe_set_ephe_path_d@4" ( _
  545. ByVal path As String _
  546. ) As Long
  547. Public Declare Sub swe_set_jpl_file Lib "swedll32.dll" _
  548. Alias "_swe_set_jpl_file@4" ( _
  549. ByVal file As String _
  550. )
  551. Public Declare Function swe_set_jpl_file_d Lib "swedll32.dll" _
  552. Alias "_swe_set_jpl_file_d@4" ( _
  553. ByVal file As String _
  554. ) As Long
  555. Public Declare Function swe_set_sid_mode Lib "swedll32.dll" _
  556. Alias "_swe_set_sid_mode@20" ( _
  557. ByVal sid_mode As Long, _
  558. ByVal t0 As Double, _
  559. ByVal ayan_t0 As Double _
  560. ) As Long
  561. Public Declare Function swe_set_sid_mode_d Lib "swedll32.dll" _
  562. Alias "_swe_sid_mode_d@12" ( _
  563. ByVal sid_mode As Long, _
  564. ByRef t0 As Double, _
  565. ByRef ayan_t0 As Double _
  566. ) As Long
  567. Public Declare Function swe_set_topo Lib "swedll32.dll" _
  568. Alias "_swe_set_topo@24" ( _
  569. ByVal geolon As Double, _
  570. ByVal geolat As Double, _
  571. ByVal altitude As Double _
  572. ) As Long
  573. Public Declare Function swe_set_topo_d Lib "swedll32.dll" _
  574. Alias "_swe_set_topo_d@12" ( _
  575. ByRef geolon As Double, _
  576. ByRef geolat As Double, _
  577. ByRef altitude As Double _
  578. )
  579. Public Declare Sub swe_set_tid_acc Lib "swedll32.dll" _
  580. Alias "_swe_set_tid_acc@8" ( _
  581. ByVal x As Double _
  582. )
  583. Public Declare Function swe_set_tid_acc_d Lib "swedll32.dll" _
  584. Alias "_swe_set_tid_acc_d@4" ( _
  585. ByRef x As Double _
  586. ) As Long
  587. Public Declare Function swe_sidtime0 Lib "swedll32.dll" _
  588. Alias "_swe_sidtime0@24" ( _
  589. ByVal tjd_ut As Double, _
  590. ByVal ecl As Double, _
  591. ByVal nut As Double _
  592. ) As Double
  593. Public Declare Function swe_sidtime0_d Lib "swedll32.dll" _
  594. Alias "_swe_sidtime0_d@16" ( _
  595. ByRef tjd_ut As Double, _
  596. ByRef ecl As Double, _
  597. ByRef nut As Double, _
  598. ByRef sidt As Double _
  599. ) As Long
  600. Public Declare Function swe_sidtime Lib "swedll32.dll" _
  601. Alias "_swe_sidtime@8" ( _
  602. ByVal tjd_ut As Double _
  603. ) As Double
  604. Public Declare Function swe_sidtime_d Lib "swedll32.dll" _
  605. Alias "_swe_sidtime_d@8" ( _
  606. ByRef tjd_ut As Double, _
  607. ByRef sidt As Double _
  608. ) As Long
  609. Public Declare Function swe_sol_eclipse_how Lib "swedll32.dll" _
  610. Alias "_swe_sol_eclipse_how@24" ( _
  611. ByVal tjd_ut As Double, _
  612. ByVal ifl As Long, _
  613. ByRef geopos As Double, _
  614. ByRef attr As Double, _
  615. ByVal serr As String _
  616. ) As Long
  617. Public Declare Function swe_sol_eclipse_how_d Lib "swedll32.dll" _
  618. Alias "_swe_sol_eclipse_how_d@20" ( _
  619. ByRef tjd_ut As Double, _
  620. ByVal ifl As Long, _
  621. ByRef geopos As Double, _
  622. ByRef attr As Double, _
  623. ByVal serr As String _
  624. ) As Long
  625. Public Declare Function swe_sol_eclipse_when_glob Lib "swedll32.dll" _
  626. Alias "_swe_sol_eclipse_when_glob@28" ( _
  627. ByVal tjd_start As Double, _
  628. ByVal ifl As Long, _
  629. ByVal ifltype As Long, _
  630. ByRef tret As Double, _
  631. ByVal backward As Long, _
  632. ByVal serr As String _
  633. ) As Long
  634. Public Declare Function swe_sol_eclipse_when_glob_d Lib "swedll32.dll" _
  635. Alias "_swe_sol_eclipse_when_glob_d@24" ( _
  636. ByRef tjd_start As Double, _
  637. ByVal ifl As Long, _
  638. ByVal ifltype As Long, _
  639. ByRef tret As Double, _
  640. ByVal backward As Long, _
  641. ByVal serr As String _
  642. ) As Long
  643. Public Declare Function swe_sol_eclipse_when_loc Lib "swedll32.dll" _
  644. Alias "_swe_sol_eclipse_when_loc@32" ( _
  645. ByVal tjd_start As Double, _
  646. ByVal ifl As Long, _
  647. ByRef tret As Double, _
  648. ByRef attr As Double, _
  649. ByVal backward As Long, _
  650. ByVal serr As String _
  651. ) As Long
  652. Public Declare Function swe_sol_eclipse_when_loc_d Lib "swedll32.dll" _
  653. Alias "_swe_sol_eclipse_when_loc_d@28" ( _
  654. ByRef tjd_start As Double, _
  655. ByVal ifl As Long, _
  656. ByRef tret As Double, _
  657. ByRef attr As Double, _
  658. ByVal backward As Long, _
  659. ByVal serr As String _
  660. ) As Long
  661. Public Declare Function swe_sol_eclipse_where Lib "swedll32.dll" _
  662. Alias "_swe_sol_eclipse_where@24" ( _
  663. ByVal tjd_ut As Double, _
  664. ByVal ifl As Long, _
  665. ByRef geopos As Double, _
  666. ByRef attr As Double, _
  667. ByVal serr As String _
  668. ) As Long
  669. Public Declare Function swe_sol_eclipse_where_d Lib "swedll32.dll" _
  670. Alias "_swe_sol_eclipse_where_d@20" ( _
  671. ByRef tjd_ut As Double, _
  672. ByVal ifl As Long, _
  673. ByRef geopos As Double, _
  674. ByRef attr As Double, _
  675. ByVal serr As String _
  676. ) As Long
  677. Public Declare Function swe_time_equ Lib "swedll32.dll" _
  678. Alias "_swe_time_equ@16" ( _
  679. ByVal tjd_ut As Double, _
  680. ByRef E As Double, _
  681. ByRef serr As String _
  682. ) As Long
  683. ' values for gregflag in swe_julday() and swe_revjul()
  684. Public Const SE_JUL_CAL As Integer = 0
  685. Public Const SE_GREG_CAL As Integer = 1
  686. ' planet and body numbers (parameter ipl) for swe_calc()
  687. Public Const SE_ECL_NUT As Integer = -1
  688. Public Const SE_SUN As Integer = 0
  689. Public Const SE_MOON As Integer = 1
  690. Public Const SE_MERCURY As Integer = 2
  691. Public Const SE_VENUS As Integer = 3
  692. Public Const SE_MARS As Integer = 4
  693. Public Const SE_JUPITER As Integer = 5
  694. Public Const SE_SATURN As Integer = 6
  695. Public Const SE_URANUS As Integer = 7
  696. Public Const SE_NEPTUNE As Integer = 8
  697. Public Const SE_PLUTO As Integer = 9
  698. Public Const SE_MEAN_NODE As Integer = 10
  699. Public Const SE_TRUE_NODE As Integer = 11
  700. Public Const SE_MEAN_APOG As Integer = 12
  701. Public Const SE_OSCU_APOG As Integer = 13
  702. Public Const SE_EARTH As Integer = 14
  703. Public Const SE_CHIRON As Integer = 15
  704. Public Const SE_PHOLUS As Integer = 16
  705. Public Const SE_CERES As Integer = 17
  706. Public Const SE_PALLAS As Integer = 18
  707. Public Const SE_JUNO As Integer = 19
  708. Public Const SE_VESTA As Integer = 20
  709. Public Const SE_NPLANETS As Integer = 21
  710. Public Const SE_AST_OFFSET As Integer = 10000
  711. ' Hamburger or Uranian ficticious "planets"
  712. Public Const SE_FICT_OFFSET As Integer = 40
  713. Public Const SE_FICT_MAX As Integer = 999 'maximum number for ficticious planets
  714. 'if taken from file seorbel.txt
  715. Public Const SE_NFICT_ELEM As Integer = 15 'number of built-in ficticious planets
  716. Public Const SE_CUPIDO As Integer = 40
  717. Public Const SE_HADES As Integer = 41
  718. Public Const SE_ZEUS As Integer = 42
  719. Public Const SE_KRONOS As Integer = 43
  720. Public Const SE_APOLLON As Integer = 44
  721. Public Const SE_ADMETOS As Integer = 45
  722. Public Const SE_VULKANUS As Integer = 46
  723. Public Const SE_POSEIDON As Integer = 47
  724. ' other ficticious bodies
  725. Public Const SE_ISIS As Integer = 48
  726. Public Const SE_NIBIRU As Integer = 49
  727. Public Const SE_HARRINGTON As Integer = 50
  728. Public Const SE_NEPTUNE_LEVERRIER As Integer = 51
  729. Public Const SE_NEPTUNE_ADAMS As Integer = 52
  730. Public Const SE_PLUTO_LOWELL As Integer = 53
  731. Public Const SE_PLUTO_PICKERING As Integer = 54
  732. ' points returned by swe_houses() and swe_houses_armc()
  733. ' in array ascmc(0...10)
  734. Public Const SE_ASC As Integer = 0
  735. Public Const SE_MC As Integer = 1
  736. Public Const SE_ARMC As Integer = 2
  737. Public Const SE_VERTEX As Integer = 3
  738. Public Const SE_EQUASC As Integer = 4 ' "equatorial ascendant"
  739. Public Const SE_NASCMC As Integer = 5 ' number of such points
  740. ' iflag values for swe_calc()/swe_calc_ut() and
  741. ' swe_fixstar()/swe_fixstar_ut()
  742. Public Const SEFLG_JPLEPH As Long = 1
  743. Public Const SEFLG_SWIEPH As Long = 2
  744. Public Const SEFLG_MOSEPH As Long = 4
  745. Public Const SEFLG_SPEED As Long = 256
  746. Public Const SEFLG_HELCTR As Long = 8
  747. Public Const SEFLG_TRUEPOS As Long = 16
  748. Public Const SEFLG_J2000 As Long = 32
  749. Public Const SEFLG_NONUT As Long = 64
  750. Public Const SEFLG_NOGDEFL As Long = 512
  751. Public Const SEFLG_NOABERR As Long = 1024
  752. Public Const SEFLG_EQUATORIAL As Long = 2048
  753. Public Const SEFLG_XYZ As Long = 4096
  754. Public Const SEFLG_RADIANS As Long = 8192
  755. Public Const SEFLG_BARYCTR As Long = 16384
  756. Public Const SEFLG_TOPOCTR As Long = 32768
  757. Public Const SEFLG_SIDEREAL As Long = 65536
  758. 'eclipse codes
  759. Public Const SE_ECL_CENTRAL As Long = 1
  760. Public Const SE_ECL_NONCENTRAL As Long = 2
  761. Public Const SE_ECL_TOTAL As Long = 4
  762. Public Const SE_ECL_ANNULAR As Long = 8
  763. Public Const SE_ECL_PARTIAL As Long = 16
  764. Public Const SE_ECL_ANNULAR_TOTAL As Long = 32
  765. Public Const SE_ECL_PENUMBRAL As Long = 64
  766. Public Const SE_ECL_VISIBLE As Long = 128
  767. Public Const SE_ECL_MAX_VISIBLE As Long = 256
  768. Public Const SE_ECL_1ST_VISIBLE As Long = 512
  769. Public Const SE_ECL_2ND_VISIBLE As Long = 1024
  770. Public Const SE_ECL_3RD_VISIBLE As Long = 2048
  771. Public Const SE_ECL_4TH_VISIBLE As Long = 4096
  772. 'sidereal modes, for swe_set_sid_mode()
  773. Public Const SE_SIDM_FAGAN_BRADLEY As Long = 0
  774. Public Const SE_SIDM_LAHIRI As Long = 1
  775. Public Const SE_SIDM_DELUCE As Long = 2
  776. Public Const SE_SIDM_RAMAN As Long = 3
  777. Public Const SE_SIDM_USHASHASHI As Long = 4
  778. Public Const SE_SIDM_KRISHNAMURTI As Long = 5
  779. Public Const SE_SIDM_DJWHAL_KHUL As Long = 6
  780. Public Const SE_SIDM_YUKTESHWAR As Long = 7
  781. Public Const SE_SIDM_JN_BHASIN As Long = 8
  782. Public Const SE_SIDM_BABYL_KUGLER1 As Long = 9
  783. Public Const SE_SIDM_BABYL_KUGLER2 As Long = 10
  784. Public Const SE_SIDM_BABYL_KUGLER3 As Long = 11
  785. Public Const SE_SIDM_BABYL_HUBER As Long = 12
  786. Public Const SE_SIDM_BABYL_ETPSC As Long = 13
  787. Public Const SE_SIDM_ALDEBARAN_15TAU As Long = 14
  788. Public Const SE_SIDM_HIPPARCHOS As Long = 15
  789. Public Const SE_SIDM_SASSANIAN As Long = 16
  790. Public Const SE_SIDM_GALCENT_0SAG As Long = 17
  791. Public Const SE_SIDM_J2000 As Long = 18
  792. Public Const SE_SIDM_J1900 As Long = 19
  793. Public Const SE_SIDM_B1950 As Long = 20
  794. Public Const SE_SIDM_USER As Long = 255
  795. Public Const SE_NSIDM_PREDEF As Long = 21
  796. Public Const SE_SIDBITS As Long = 256
  797. 'for projection onto ecliptic of t0
  798. Public Const SE_SIDBIT_ECL_T0 As Long = 256
  799. 'for projection onto solar system plane
  800. Public Const SE_SIDBIT_SSY_PLANE As Long = 512
  801. ' modes for planetary nodes/apsides, swe_nod_aps(), swe_nod_aps_ut()
  802. Public Const SE_NODBIT_MEAN As Long = 1
  803. Public Const SE_NODBIT_OSCU As Long = 2
  804. Public Const SE_NODBIT_OSCU_BAR As Long = 3
  805. Public Const SE_NODBIT_FOPOINT As Long = 256
  806. ' indices for swe_rise_trans()
  807. Public Const SE_CALC_RISE As Long = 1
  808. Public Const SE_CALC_SET As Long = 2
  809. Public Const SE_CALC_MTRANSIT As Long = 4
  810. Public Const SE_CALC_ITRANSIT As Long = 8
  811. ' bits for data conversion with swe_azalt() and swe_azalt_rev()
  812. Public Const SE_ECL2HOR As Long = 0
  813. Public Const SE_EQU2HOR As Long = 1
  814. Public Const SE_HOR2ECL As Long = 0
  815. Public Const SE_HOR2EQU As Long = 1
  816. ' for swe_refrac()
  817. Public Const SE_TRUE_TO_APP As Long = 0
  818. Public Const SE_APP_TO_TRUE As Long = 1
  819. ' ------------------------------------------------------------------
  820. ' The rest of this module contains functions and data
  821. ' based on the Swiss Ephemeris
  822. ' related with calendar computations
  823. ' ------------------------------------------------------------------
  824. ' Short Names for signs
  825. Const sknam As String = "ARTAGECNLEVILISCSACPAQPS"
  826. Dim cuspName As Variant
  827. Public Function DegMin(x As Double) As String
  828. Dim y As Double
  829. Dim suffix As String
  830. Dim mins As Integer
  831. Dim degs As Integer
  832. y = (x / 360 - Int(x / 360)) * 360
  833. suffix = Mid(sknam, 1 + 2 * Int(y / 30), 2)
  834. y = y - 30 * Int(y / 30)
  835. degs = Int(y)
  836. If degs < 10 Then
  837. DegMin = " " & degs
  838. Else
  839. DegMin = degs
  840. End If
  841. y = (y - degs) * 60
  842. mins = Int(y)
  843. If mins < 10 Then
  844. DegMin = DegMin & "° " & mins
  845. Else
  846. DegMin = DegMin & "°" & mins
  847. End If
  848. DegMin = DegMin & "'" & suffix
  849. End Function
  850. Public Function Dms(x As Double, Optional dmsType As Long = 0) As String
  851. Dim y As Double, l As Double, degs As Integer, _
  852. mins As Integer, secs As Integer, _
  853. suffix As String
  854. y = (x / 360 - Int(x / 360)) * 360
  855. suffix = getSuffix(Int(y / 30), dmsType)
  856. y = y - 30 * Int(y / 30)
  857. l = y
  858. degs = Int(y)
  859. If degs < 10 Then
  860. Dms = " " & degs
  861. Else
  862. Dms = degs
  863. End If
  864. y = (y - degs) * 60
  865. mins = Int(y)
  866. If mins < 10 Then
  867. Dms = Dms & "° " & mins
  868. Else
  869. Dms = Dms & "°" & mins
  870. End If
  871. y = (y - mins) * 60
  872. If y > 59 And l > 29.983333 Then
  873. secs = 59
  874. Else
  875. secs = Int(y + 0.5)
  876. End If
  877. If secs < 10 Then
  878. Dms = Dms & "' " & secs
  879. Else
  880. Dms = Dms & "'" & secs
  881. End If
  882. Dms = Dms & """ " & suffix
  883. End Function
  884. Function getSuffix(i As Long, Optional dmsType As Long = 0) As String
  885. Select Case dmsType
  886. Case 0
  887. getSuffix = Mid(sknam, 1 + 2 * i, 2)
  888. Case 1
  889. If IsEmpty(cuspName) Then
  890. cuspName = Array("I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI", "XII")
  891. End If
  892. getSuffix = cuspName(i)
  893. End Select
  894. End Function
  895. Public Function Dms360(x As Double) As String
  896. Dim y As Double, degs As Integer, _
  897. mins As Integer, secs As Integer
  898. y = x + 0.5 / 3600
  899. y = (y / 360 - Int(y / 360)) * 360
  900. degs = Int(y)
  901. If degs >= 100 Then
  902. Dms360 = degs
  903. Else
  904. If degs >= 10 Then
  905. Dms360 = " " & degs
  906. Else
  907. Dms360 = " " & degs
  908. End If
  909. End If
  910. y = (y - degs) * 60
  911. mins = Int(y)
  912. If mins < 10 Then
  913. Dms360 = Dms360 & "° " & mins
  914. Else
  915. Dms360 = Dms360 & "°" & mins
  916. End If
  917. y = (y - mins) * 60
  918. secs = Int(y)
  919. If secs < 10 Then
  920. Dms360 = Dms360 & "' " & secs
  921. Else
  922. Dms360 = Dms360 & "'" & secs
  923. End If
  924. Dms360 = Dms360 & """"
  925. End Function
  926. Public Function Deg(x As Double) As Double
  927. Dim s, y, grade, minuten, sekunden
  928. s = Sgn(x)
  929. y = x * s + 0.0000000001
  930. grade = Int(y)
  931. minuten = Int((y - grade) * 100)
  932. sekunden = Int((y * 100 - Int(y * 100)) * 100000) / 1000
  933. Deg = s * (grade + minuten / 60 + sekunden / 3600)
  934. End Function
  935. Public Function Hms(x As Double, Optional round As Boolean = True) As String
  936. Dim y, degs, mins, secs
  937. If round Then y = x + 0.5 / 3600 Else y = x
  938. y = (y / 24 - Int(y / 24)) * 24
  939. degs = Int(y)
  940. If degs < 10 Then
  941. Hms = " " & degs
  942. Else
  943. Hms = degs
  944. End If
  945. y = (y - degs) * 60
  946. mins = Int(y)
  947. If mins < 10 Then
  948. Hms = Hms & "h " & mins
  949. Else
  950. Hms = Hms & "h" & mins
  951. End If
  952. y = (y - mins) * 60
  953. secs = Int(y)
  954. If secs < 10 Then
  955. Hms = Hms & "m " & secs
  956. Else
  957. Hms = Hms & "m" & secs
  958. End If
  959. Hms = Hms & "s "
  960. End Function
  961. Public Function ArcDiff(x As Double, y As Double)
  962. ArcDiff = x - y - Int((x - y) / 360 + 0.5) * 360
  963. End Function
  964. Public Function AbsArcDiff(x As Double, y As Double)
  965. AbsArcDiff = x - y - Int((x - y) / 360 + 0.5) * 360
  966. If AbsArcDiff < 0 Then AbsArcDiff = -AbsArcDiff
  967. End Function
  968. Public Function Mod360(x As Double) As Double
  969. Mod360 = x - Int(x / 360) * 360
  970. End Function
  971. Public Function Asn(x As Double) As Double
  972. Asn = Atn(x / Sqr(-x * x + 1))
  973. End Function
  974. ' Reset the length of a zero-terminated string
  975. ' Necessary for communication with Swiss Ephemeris
  976. Public Function trim0(c$) As String
  977. Dim i As Integer
  978. i = InStr(c$, Chr$(0))
  979. If i > 0 Then
  980. trim0 = Left(c$, i - 1)
  981. End If
  982. End Function
  983. Public Function JulianDayNumber(dateString As String, time As Double)
  984. Dim x As Variant, gregflag As Long
  985. x = Split(dateString, ".")
  986. If UBound(x) <> 2 Then
  987. JulianDayNumber = 0
  988. Exit Function
  989. End If
  990. If Right$(x(2), 1) = "j" Then
  991. gregflag = SE_JUL_CAL
  992. x(2) = Left$(x(2), Len(x(2)) - 1)
  993. Else
  994. If Right$(x(2), 1) = "g" Then
  995. gregflag = SE_GREG_CAL
  996. x(2) = Left$(x(2), Len(x(2)) - 1)
  997. Else
  998. ' Default rule for determination of calendar flag:
  999. ' Take Julian calendar before 15.10.1582
  1000. If x(2) < 1582 Or ( _
  1001. x(2) = 1582 And ( _
  1002. x(1) < 10 Or _
  1003. x(1) = 10 And x(0) < 15) _
  1004. ) _
  1005. Then
  1006. gregflag = SE_JUL_CAL
  1007. Else
  1008. gregflag = SE_GREG_CAL
  1009. End If
  1010. End If
  1011. End If
  1012. JulianDayNumber = swe_julday(x(2), x(1), x(0), time, gregflag)
  1013. End Function
  1014. Public Function calendarDate(jd As Double, Optional iCalFlag As Long = -1) As String
  1015. Dim day As Long, month As Long, year As Long
  1016. Dim hour As Double
  1017. Dim calflag
  1018. If iCalFlag > -1 Then
  1019. calflag = iCalFlag
  1020. Else
  1021. If jd < 2299171 Then
  1022. calflag = SE_JUL_CAL
  1023. Else
  1024. calflag = SE_GREG_CAL
  1025. End If
  1026. End If
  1027. Call swe_revjul(jd, calflag, year, month, day, hour)
  1028. calendarDate = day & "." & month & "." & year
  1029. End Function
  1030. ' Compute Julian Day Number in Ephemeris Time from calendar date in UT
  1031. Public Function jd_from_date_ut(caldate As String, ut As String) As Double
  1032. Dim x As Variant
  1033. Dim t As Double
  1034. If caldate = "" Then
  1035. jd_from_date_ut = 0
  1036. Exit Function
  1037. End If
  1038. t = time_to_double(ut)
  1039. ' Compute Day number from date string and time as double
  1040. jd_from_date_ut = JulianDayNumber(caldate, t)
  1041. If jd_from_date_ut <> 0 Then
  1042. ' Correct with Delta T
  1043. jd_from_date_ut = jd_from_date_ut + swe_deltat(jd_from_date_ut)
  1044. End If
  1045. End Function
  1046. ' Parse a time string with hours, minutes and seconds into a double number representing the hours
  1047. Public Function time_to_double(time As String) As Double
  1048. Dim y As Variant, z As Variant, z1 As Variant
  1049. Dim h As Long, m As Long, s As Long
  1050. If time = "" Then
  1051. time_to_double = 0
  1052. Exit Function
  1053. End If
  1054. y = Split(time, "h")
  1055. h = y(0)
  1056. If y(1) = "" Then
  1057. m = 0
  1058. s = 0
  1059. Else
  1060. z = Split(y(1), "m")
  1061. m = z(0)
  1062. If UBound(z) = 0 Then
  1063. s = 0
  1064. ElseIf z(1) = "" Then
  1065. s = 0
  1066. Else
  1067. z1 = Split(z(1), "s")
  1068. s = z1(0)
  1069. End If
  1070. End If
  1071. time_to_double = h + m / 60 + s / 3600
  1072. End Function
  1073. Function time_from_jd(jd As Double) As String
  1074. time_from_jd = Hms((jd + 0.5 - Int(jd + 0.5)) * 24)
  1075. End Function
  1076. Function time_from_jd_no_round(jd As Double) As String
  1077. time_from_jd_no_round = Hms((jd + 0.5 - Int(jd + 0.5)) * 24, False)
  1078. End Function
  1079. Function ut_from_jd(jd_et As Double) As String
  1080. ut_from_jd = time_from_jd(jd_et - swe_deltat(jd_et))
  1081. End Function