Skip to content

Commit abf19df

Browse files
authored
Remove implicit floats in definition of AstroPeriod (#81) and bump version 0.7.3
* Remove implicit floats in definition of `AstroPeriod` * Define period constants as `Int64` instead of machine integer * Bump version 0.7.3
1 parent 310980f commit abf19df

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "AstroTime"
22
uuid = "c61b5328-d09d-5e37-a9a8-0eb41c39009c"
3-
version = "0.7.2"
3+
version = "0.7.3"
44

55
[deps]
66
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"

src/Periods.jl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ export AstroPeriod, TimeUnit,
1111
SECONDS_PER_YEAR,
1212
SECONDS_PER_CENTURY
1313

14-
const SECONDS_PER_MINUTE = 60.0
15-
const SECONDS_PER_HOUR = 60.0 * 60.0
16-
const SECONDS_PER_DAY = 60.0 * 60.0 * 24.0
17-
const SECONDS_PER_YEAR = 60.0 * 60.0 * 24.0 * 365.25
18-
const SECONDS_PER_CENTURY = 60.0 * 60.0 * 24.0 * 365.25 * 100.0
14+
const SECONDS_PER_MINUTE = 60 |> Int64
15+
const SECONDS_PER_HOUR = 60 * SECONDS_PER_MINUTE |> Int64
16+
const SECONDS_PER_DAY = 24 * SECONDS_PER_HOUR |> Int64
17+
# Julian year, turns out to be an integer number of seconds in a year
18+
# despite it containing a fraction of a day
19+
const SECONDS_PER_YEAR = (365+1//4) * SECONDS_PER_DAY |> Int64
20+
const SECONDS_PER_CENTURY = 100 * SECONDS_PER_YEAR |> Int64
1921

2022
"""
2123
All time units are subtypes of the abstract type `TimeUnit`.
@@ -46,7 +48,7 @@ const centuries = Century()
4648

4749
Base.broadcastable(u::TimeUnit) = Ref(u)
4850

49-
factor(::Second) = 1.0
51+
factor(::Second) = 1
5052
factor(::Minute) = SECONDS_PER_MINUTE
5153
factor(::Hour) = SECONDS_PER_HOUR
5254
factor(::Day) = SECONDS_PER_DAY

test/periods.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,3 @@
103103
@test (1:3) * seconds === seconds * (1:3)
104104
@test (1:3) * seconds isa AbstractRange
105105
end
106-

0 commit comments

Comments
 (0)