Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added getModifiedJulianDate() to epoch module in @observerly/astrometry. #8

Merged
merged 1 commit into from
Aug 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/epoch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,18 @@ export const getJulianDate = (datetime: Date): number => {
}

/*****************************************************************************************************************/

/**
*
* getModifiedJulianDate()
*
*
* @param date - The date for which to calculate the Modified Julian Date (MJD).
* @returns Modified Julian Date as number - the Modified Julian Date (MJD) of the given date normalised to UTC.
*
*/
export const getModifiedJulianDate = (datetime: Date): number => {
return getJulianDate(datetime) - 2400000.5
}

/*****************************************************************************************************************/
15 changes: 14 additions & 1 deletion tests/epoch.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { describe, expect, it } from 'vitest'

/*****************************************************************************************************************/

import { getJulianDate } from '../src'
import { getJulianDate, getModifiedJulianDate } from '../src'

/*****************************************************************************************************************/

Expand All @@ -32,3 +32,16 @@ describe('getJulianDate', () => {
})

/*****************************************************************************************************************/

describe('Modified Julian Date', () => {
it('should be defined', () => {
expect(getModifiedJulianDate).toBeDefined()
})

it('should return the Modified Julian Date (MJD) of the given date', () => {
const MJD = getModifiedJulianDate(datetime)
expect(MJD).toBe(59348)
})
})

/*****************************************************************************************************************/
Loading