Skip to content

Commit

Permalink
Small refactor
Browse files Browse the repository at this point in the history
Signed-off-by: Cédric Foellmi <cedric@onekiloparsec.dev>
  • Loading branch information
onekiloparsec committed Nov 19, 2023
1 parent 47eae3d commit 113aa52
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/risetransitset/accurate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import Decimal from '@/decimal'
import { Degree, EquatorialCoordinates, GeographicCoordinates, JulianDay, LengthArray, RiseTransitSet } from '@/types'
import { getJulianDayMidnight, getLocalSiderealTime } from '@/juliandays'
import { STANDARD_ALTITUDE_STARS } from '@/constants'
import { getJDatUTC } from '@/utils'
import { getDeltaT } from '@/times'
import { getDeltaMTimes } from './deltamtimes'
import { getMTimes, MTimes } from './mtimes'
import { getJDatUTC } from './utils'


/**
Expand Down
2 changes: 1 addition & 1 deletion src/risetransitset/standard.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Decimal from '@/decimal'
import { getJDatUTC } from '@/utils'
import { STANDARD_ALTITUDE_STARS } from '@/constants'
import {
Degree,
Expand All @@ -11,6 +10,7 @@ import {
RiseTransitSet
} from '@/types'
import { getMTimes, MTimesNum } from './mtimes'
import { getJDatUTC } from './utils'

/**
* Compute the times of rise, set and transit of an object at a given date,
Expand Down
16 changes: 16 additions & 0 deletions src/risetransitset/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Hour, JulianDay } from '@/types'
import dayjs from 'dayjs'
import { getDate, getJulianDay } from '@/juliandays'
import { getSexagesimalValue } from '@/sexagesimal'

export function getJDatUTC (jd: JulianDay | number, utc: Hour | number): JulianDay {
const utcMoment = dayjs.utc(getDate(jd))
const sexa = getSexagesimalValue(utc)
return getJulianDay(
utcMoment
.hour(sexa.radix.toNumber())
.minute(sexa.minutes.toNumber())
.second(sexa.seconds.toNumber())
.toDate()
)!
}
12 changes: 0 additions & 12 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,3 @@ export function fmod90 (degrees: Degree | number): Degree {

return result
}

export function getJDatUTC (jd: JulianDay | number, utc: Hour | number): JulianDay {
const utcMoment = dayjs.utc(getDate(jd))
const sexa = getSexagesimalValue(utc)
return getJulianDay(
utcMoment
.hour(sexa.radix.toNumber())
.minute(sexa.minutes.toNumber())
.second(sexa.seconds.toNumber())
.toDate()
)!
}

0 comments on commit 113aa52

Please sign in to comment.