-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from JuliaSpaceMissionDesign/dev
v1.3.0
- Loading branch information
Showing
17 changed files
with
282 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,8 +12,8 @@ jobs: | |
fail-fast: false | ||
matrix: | ||
version: | ||
- '1.8' | ||
- '1.9' | ||
- '1.10' | ||
- '1' | ||
os: | ||
- ubuntu-latest | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,11 @@ find_dayinyear | |
|
||
## Epochs | ||
|
||
### Duration | ||
```@docs | ||
Duration | ||
``` | ||
|
||
### Types | ||
```@docs | ||
Epoch | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
|
||
""" | ||
Duration{T} | ||
A `Duration` represents a period of time, split into an integer number of seconds and a | ||
fractional part. | ||
### Fields | ||
- `seconds`: The integer number of seconds. | ||
- `fraction`: The fractional part of the duration, where `T` is a subtype of `Number`. | ||
""" | ||
struct Duration{T} | ||
seconds::Int | ||
fraction::T | ||
end | ||
|
||
function Duration(seconds::T) where {T<:Number} | ||
i, f = divrem(seconds, 1) | ||
return Duration{T}(i, f) | ||
end | ||
|
||
function Duration(sec::Int, frac::T) where {T<:Number} | ||
return Duration{T}(sec, frac) | ||
end | ||
|
||
value(d::Duration{T}) where T = d.seconds + d.fraction | ||
|
||
function Base.isless(d::Duration{T}, q::Number) where T | ||
return value(d) < q | ||
end | ||
|
||
function Base.isless(d::Duration{T1}, d2::Duration{T2}) where {T1, T2} | ||
return value(d) < value(d2) | ||
end | ||
|
||
function fmasf(a, b, mul) | ||
amulb = fma(mul, a, b) | ||
i, f = divrem(amulb, 1) | ||
return i, f | ||
end | ||
|
||
function Base.:-(d1::Duration, d2::Duration) | ||
s1, f1 = d1.seconds, d1.fraction | ||
s2, f2 = d2.seconds, d2.fraction | ||
ds, df = divrem(f1 - f2, 1) | ||
sec = s1 - s2 + ds | ||
if df < 0 | ||
sec -= 1 | ||
df += 1 | ||
end | ||
return Duration(convert(Int, sec), df) | ||
end | ||
|
||
function Base.:+(d1::Duration, d2::Duration) | ||
s1, f1 = d1.seconds, d1.fraction | ||
s2, f2 = d2.seconds, d2.fraction | ||
s, f = fmasf(f1, f2, 1) | ||
return Duration(convert(Int, s1 + s2 + s), f) | ||
end | ||
|
||
function Base.:+(d::Duration, x::Number) | ||
es, ef = d.seconds, d.fraction | ||
xs, xf = divrem(x, 1) | ||
s, f = fmasf(ef, xf, 1) | ||
return Duration(convert(Int, es + xs + s), f) | ||
end | ||
|
||
function Base.:-(d::Duration, x::Number) | ||
es, ef = d.seconds, d.fraction | ||
xs, xf = divrem(x, 1) | ||
ds, df = divrem(ef - xf, 1) | ||
sec = es - xs + ds | ||
if df < 0 | ||
sec -= 1 | ||
df += 1 | ||
end | ||
return Duration(convert(Int, sec), df) | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
944f79e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register
Release notes:
944f79e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/108528
Tagging
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: