JuliaAstro / AstroTime.jl

Astronomical time keeping in Julia
https://juliaastro.github.io/AstroTime.jl/stable/
Other
38 stars 10 forks source link

Custom Time Scale inside module #66

Open zsoerenm opened 3 years ago

zsoerenm commented 3 years ago

If I define a custom time scale inside a package, conversion will not work:

module FooBar

using AstroTime

@timescale GPSTime TAI
AstroTime.Epochs.getoffset(
    ::GPSTimeScale, 
    ::InternationalAtomicTime, 
    second, 
    fraction) = 19
AstroTime.Epochs.getoffset(
    ::InternationalAtomicTime, 
    ::GPSTimeScale, 
    second, 
    fraction) = -19

end

Note that when copying this into the REPL, it will actually work. It does not work when it is a real package (not a module inside Main). I get the following error:

julia> using FooBar, AstroTime
julia> TAIEpoch(FooBar.GPSTimeEpoch(2021,5,31))
ERROR: No conversion path between 'GPSTime' and 'TAI' available.
Stacktrace:
 [1] apply_offset
   @ ~/.julia/packages/AstroTime/944cN/src/Epochs/offsets.jl:154 [inlined]
 [2] (TAIEpoch{T} where T)(ep::Epoch{IGS.GPSTimeScale, Float64})
   @ AstroTime.Epochs ~/.julia/packages/AstroTime/944cN/src/Epochs/offsets.jl:39
 [3] top-level scope
   @ REPL[3]:1