Skip to content

Commit d254c23

Browse files
committed
removing day-js dependency
Signed-off-by: Cédric Foellmi <cedric@onekiloparsec.dev>
1 parent e6a6d90 commit d254c23

7 files changed

Lines changed: 9 additions & 29 deletions

File tree

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ aa-js
33

44
![build and test](https://github.com/onekiloparsec/aa-js/actions/workflows/nodejs.yml/badge.svg?branch=master) [![codecov](https://codecov.io/gh/onekiloparsec/aa-js/graph/badge.svg?token=EfRJpZ4OTu)](https://codecov.io/gh/onekiloparsec/aa-js)
55

6-
A fairly comprehensive collection of accurate astronomical algorithms (AA) in JavaScript (TypeScript).
6+
A fairly comprehensive collection of accurate astronomical algorithms (AA) in JavaScript (TypeScript).
77
It started as an implementation of AA, but it is not yet complete.
88

9+
`aa-js` has **zero runtime dependencies**.
10+
911
At the beginning, `aa-js` is the port in javascript of the C++ implementation of Astronomical
1012
Algorithms by J.P. Naughter, called [AA+](http://www.naughter.com/aa.html),
1113
based on the reference text book by Jean Meeus. It is written in TypeScript, and

package-lock.json

Lines changed: 0 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@
5454
"url": "https://github.com/onekiloparsec/aa-js/issues"
5555
},
5656
"homepage": "https://github.com/onekiloparsec/aa-js#readme",
57-
"dependencies": {
58-
"dayjs": "^1.11.19"
59-
},
6057
"devDependencies": {
6158
"@vitest/coverage-v8": "^4.0.18",
6259
"chokidar-cli": "^3.0.0",

src/juliandays.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
*
44
* @module Julian Days
55
*/
6-
import dayjs from 'dayjs'
76
import { DAYMS, DEG2H, DEG2RAD, J1970, J2000, MJD_START } from './constants'
87
import { ArcSecond, Degree, Hour, JulianCentury, JulianDay, JulianMillenium, Radian } from './types'
98
import { transformUTC2TT } from '@/times'
@@ -35,7 +34,7 @@ export function getJulianDay (...args: any[]): JulianDay {
3534
return value.valueOf() / DAYMS - 0.5 + J1970
3635
} else if (value instanceof String || typeof value === 'string') {
3736
// @ts-ignore
38-
return dayjs(value).toDate().valueOf() / DAYMS - 0.5 + J1970
37+
return new Date(value).valueOf() / DAYMS - 0.5 + J1970
3938
} else if (isNumber(value)) {
4039
const year = Math.floor(value)
4140
const month = Math.floor((value - year) * 12) // the month is 0-indexed

src/risetransitset/utils.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
import { Hour, JulianDay } from '@/types'
2-
import dayjs from 'dayjs'
32
import { getDate, getJulianDay } from '@/juliandays'
43
import { getSexagesimalValue } from '@/sexagesimal'
54

65
export function getJDatUTC (jd: JulianDay, utc: Hour): JulianDay {
7-
const utcMoment = dayjs.utc(getDate(jd))
6+
const d = getDate(jd)
87
const sexa = getSexagesimalValue(utc)
9-
return getJulianDay(
10-
utcMoment
11-
.hour(sexa.radix)
12-
.minute(sexa.minutes)
13-
.second(sexa.seconds)
14-
.toDate()
15-
)!
8+
return getJulianDay(new Date(Date.UTC(
9+
d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(),
10+
sexa.radix, sexa.minutes, sexa.seconds
11+
)))!
1612
}

src/utils.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@
22
* @module Utils
33
*/
44

5-
import dayjs from 'dayjs'
6-
import utc from 'dayjs/plugin/utc'
75
import { Degree, Hour } from '@/types'
86

9-
dayjs.extend(utc)
10-
117
export function isNumber (v: any): boolean {
128
return !isNaN(parseFloat(v)) && isFinite(v)
139
}

vite.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ export default defineConfig({
3434
dedupe: [
3535
'vue',
3636
'lodash',
37-
'dayjs',
3837
],
3938
},
4039
test: {

0 commit comments

Comments
 (0)