@@ -154,11 +154,11 @@ function Epoch{S}(jd1::T, jd2::T=zero(T), args...; origin=:j2000) where {S, T<:P
154154end
155155
156156"""
157- julian_period(ep::Epoch; origin=:j2000, scale=timescale(ep), unit=days, raw=false )
157+ julian_period([T,] ep::Epoch; origin=:j2000, scale=timescale(ep), unit=days)
158158
159159Return the period since Julian Epoch `origin` within the time scale `scale` expressed in
160- `unit` for a given epoch `ep`. If `raw` is `true`, the raw value is returned instead of a
161- [`Period`](@ref) object .
160+ `unit` for a given epoch `ep`. The result is a [`Period`](@ref) object by default.
161+ If the type argument `T` is present, the result is converted to `T` instead .
162162
163163### Example ###
164164
@@ -172,11 +172,11 @@ julia> julian_period(ep; scale=TAI)
172172julia> julian_period(ep; unit=years)
17317318.100929728496464 years
174174
175- julia> julian_period(ep; raw=true )
175+ julia> julian_period(Float64, ep )
1761766611.364583333333
177177```
178178"""
179- function julian_period (ep:: Epoch ; origin= :j2000 , scale= timescale (ep), unit= days, raw = false )
179+ function julian_period (ep:: Epoch ; origin= :j2000 , scale= timescale (ep), unit= days)
180180 ep1 = Epoch (ep, scale)
181181 jd1 = unit (ep1. second * seconds)
182182 jd2 = unit (ep1. fraction * seconds)
@@ -191,8 +191,12 @@ function julian_period(ep::Epoch; origin=:j2000, scale=timescale(ep), unit=days,
191191 throw (ArgumentError (" Unknown Julian epoch: $origin " ))
192192 end
193193
194- jd = jd2 + jd1
195- return ifelse (raw, value (jd), jd)
194+ return jd2 + jd1
195+ end
196+
197+ function julian_period (:: Type{T} , ep:: Epoch ; kwargs... ) where T
198+ jd = julian_period (ep; kwargs... )
199+ return T (value (jd))
196200end
197201
198202"""
0 commit comments