Skip to content

Commit

Permalink
Merge pull request #39169 from JuliaLang/dpa/compoundperiod-periods
Browse files Browse the repository at this point in the history
Add the public `Dates.periods` function for getting the `Vector` of `Period`s that comprise a `CompoundPeriod`
  • Loading branch information
quinnj authored Jan 11, 2021
2 parents c487dd0 + dd8b43e commit 012349b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Standard library changes

#### Dates

* The `Dates.periods` function can be used to get the `Vector` of `Period`s that comprise a `CompoundPeriod` ([#39169]).

#### Statistics

Expand Down
1 change: 1 addition & 0 deletions stdlib/Dates/docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,7 @@ Dates.Period(::Any)
Dates.CompoundPeriod(::Vector{<:Dates.Period})
Dates.value
Dates.default
Dates.periods
```

### Rounding Functions
Expand Down
7 changes: 7 additions & 0 deletions stdlib/Dates/src/periods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,13 @@ struct CompoundPeriod <: AbstractTime
end
end

"""
Dates.periods(::CompoundPeriod) -> Vector{Period}
Return the `Vector` of `Period`s that comprise the given `CompoundPeriod`.
"""
periods(x::CompoundPeriod) = x.periods

"""
CompoundPeriod(periods) -> CompoundPeriod
Expand Down
1 change: 1 addition & 0 deletions stdlib/Dates/test/periods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ end
@test isequal(d - h, 2d - 2h - 1d + 1h)
@test sprint(show, y + m) == string(y + m)
@test convert(Dates.CompoundPeriod, y) + m == y + m
@test Dates.periods(convert(Dates.CompoundPeriod, y)) == convert(Dates.CompoundPeriod, y).periods
end
@testset "compound period simplification" begin
# reduce compound periods into the most basic form
Expand Down

4 comments on commit 012349b

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily package evaluation, I will reply here when finished:

@nanosoldier runtests(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your benchmark job has completed - successfully executed benchmarks. A full report can be found here. cc @christopher-dG

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your package evaluation job has completed - possible new issues were detected. A full report can be found here. cc @maleadt

Please sign in to comment.