Skip to content

Commit

Permalink
Document Dates.value (#29591)
Browse files Browse the repository at this point in the history
  • Loading branch information
amellnik authored and fredrikekre committed Oct 14, 2018
1 parent 806d7c2 commit b7a7002
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion stdlib/Dates/docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,8 @@ it could represent, in days, a value of 28, 29, 30, or 31 depending on the year
Or a year could represent 365 or 366 days in the case of a leap year. [`Period`](@ref) types are
simple [`Int64`](@ref) wrappers and are constructed by wrapping any `Int64` convertible type, i.e. `Year(1)`
or `Month(3.0)`. Arithmetic between [`Period`](@ref) of the same type behave like integers, and
limited `Period-Real` arithmetic is available.
limited `Period-Real` arithmetic is available. You can extract the underlying integer with
[`Dates.value`](@ref).

```jldoctest
julia> y1 = Dates.Year(1)
Expand All @@ -537,6 +538,9 @@ julia> y3 % y2
julia> div(y3,3) # mirrors integer division
3 years
julia> Dates.value(Dates.Millisecond(10))
10
```

## Rounding
Expand Down Expand Up @@ -740,6 +744,7 @@ Dates.toprev(::Function, ::Dates.TimeType)
```@docs
Dates.Period(::Any)
Dates.CompoundPeriod(::Vector{<:Dates.Period})
Dates.value
Dates.default
```

Expand Down
6 changes: 6 additions & 0 deletions stdlib/Dates/src/periods.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

#Period types
"""
Dates.value(x::Period) -> Int64
For a given period, return the value associated with that period. For example,
`value(Millisecond(10))` returns 10 as an integer.
"""
value(x::Period) = x.value

# The default constructors for Periods work well in almost all cases
Expand Down

2 comments on commit b7a7002

@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.

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

Please sign in to comment.