Skip to content

Commit

Permalink
test added
Browse files Browse the repository at this point in the history
  • Loading branch information
prakharcode committed Jun 6, 2018
1 parent 208ff9e commit e92386c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/conversions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -503,19 +503,19 @@ function cal2jd(iy, im, id)
throw(ArugumentError("Month is outside of the range (1,12)"))
end

ly = ((im == 2 ) && !(iy % 4) && (iy % 100 || !(iy % 400))) #check if leap year
ly = ((im == 2 ) && !Bool(iy % 4!=0) && (Bool(iy % 100!=0) || !Bool(iy % 400!=0)))? 1:0 #check if leap year

if ((id < 1) || (id > MON_LENGTH[im] + ly)))
throw(ArugumentError("Day is outside of permissible range (1, $(MON_LENGTH[im]))"))
if ((id < 1) || (id > (MON_LENGTH[im] + ly)))
println("Day is outside of permissible range (1, $(MON_LENGTH[im]))")
end

my = (im - 14)/12
iypmy = iy + my
my = (im - 14) ÷ 12
iypmy = trunc(Int,(iy + my))
jd = MJD
jd1 = ((1461 * (iypmy + 4800))/ 4)
+ (367 * Int(floor(im - 2 - 12 * my))) / 12
- (3 * ((iypmy + 4900) / 100)) / 4
+ Int(floor(id - 2432076))
jd1 = float((((1461 * (iypmy + 4800)) ÷ 4)
+ (367 * trunc(Int,(im - 2 - 12 * my))) ÷ 12
- (3 * ((iypmy + 4900) ÷ 100)) ÷ 4
+ trunc(Int,id) - 2432076))

jd, jd1
end
Expand Down
3 changes: 3 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ AstroTime.update()
for jd in 2414105.0:10.0:2488985.0
@test Epochs.diff_tdb_tt(jd, 0.5) Epochs.diff_tdb_tt(jd,0.5,0.0,0.0,0.0,0.0) atol=40e-6
end

@test Epochs.cal2jd(2000, 1, 1) == ERFA.cal2jd(2000, 1, 1)
@test Epochs.cal2jd(2016, 2, 29) == ERFA.cal2jd(2016, 2, 29)
end
@testset "Leap Seconds" begin
@test leapseconds(TTEpoch(1959,1,1)) == 0
Expand Down

0 comments on commit e92386c

Please sign in to comment.