Skip to content

Commit ccb662f

Browse files
authored
Fix incorrect division for milleseconds in JD function (#257)
Thanks @dartheditous
1 parent 9dafbfb commit ccb662f

3 files changed

Lines changed: 7 additions & 2 deletions

File tree

.changeset/millesecond-fix.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@neaps/tide-predictor": patch
3+
---
4+
5+
Fix incorrect division for milleseconds in JD function (Thanks @dartheditous)

packages/tide-predictor/src/astronomy/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const JD = (t: Date): number => {
5656
t.getUTCHours() / 24.0 +
5757
t.getUTCMinutes() / (24.0 * 60.0) +
5858
t.getUTCSeconds() / (24.0 * 60.0 * 60.0) +
59-
t.getUTCMilliseconds() / (24.0 * 60.0 * 60.0 * 1e6);
59+
t.getUTCMilliseconds() / (24.0 * 60.0 * 60.0 * 1e3);
6060
if (M <= 2) {
6161
Y = Y - 1;
6262
M = M + 12;

packages/tide-predictor/test/constituents/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe("Base constituent definitions", () => {
1515
});
1616

1717
it("it prepared constituent M2", () => {
18-
expect(constituents.M2.value(testAstro)).toBeCloseTo(537.008710124, 4);
18+
expect(constituents.M2.value(testAstro)).toBeCloseTo(537.008790781, 4);
1919
});
2020

2121
it("computes IHO nodal corrections for M2", () => {

0 commit comments

Comments
 (0)