From f745f52ba5aa875251ce5f16f1ca3f76951c7e51 Mon Sep 17 00:00:00 2001 From: Aman-Pandey-afk <77021852+Aman-Pandey-afk@users.noreply.github.com> Date: Tue, 5 Apr 2022 01:14:54 +0530 Subject: [PATCH] Fix adstring method (#74) * Fix adstring method * Add Test --- src/adstring.jl | 3 +-- test/utils-tests.jl | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/adstring.jl b/src/adstring.jl index e5f562a..867cd85 100644 --- a/src/adstring.jl +++ b/src/adstring.jl @@ -94,8 +94,7 @@ function adstring(ra::T, dec::T; precision::Int=0, Int(ra_min), ra_sec_string) end dec_sec_string = formatsec(dec_sec, precision, truncate) - dec_string = @sprintf("%+03.2d %02d %s", Int(dec_deg), - Int(dec_min), dec_sec_string) + dec_string = (dec >= 0 ? "+" : "-") * @sprintf("%02.2d %02d %s", Int(abs(dec_deg)), Int(dec_min), dec_sec_string) return string(ra_string, dec_string) end diff --git a/test/utils-tests.jl b/test/utils-tests.jl index 5999f77..70629bf 100644 --- a/test/utils-tests.jl +++ b/test/utils-tests.jl @@ -5,6 +5,7 @@ @test @inferred(adstring((30.4, -1.23), truncate=true)) == @inferred(adstring([30.4, -1.23], truncate=true)) == " 02 01 35.9 -01 13 48" + @test @inferred(adstring(15, -.5)) == " 01 00 00.0 -00 30 00" @test @inferred(adstring(19.19321, truncate=true)) == "+19 11 35.5" @test @inferred(adstring(ten(36,24,15.015), -ten(8,24,36.0428), precision=3)) == " 02 25 37.0010 -08 24 36.043"