Skip to content

Commit be62b3d

Browse files
author
Christopher Doris
committed
docs(numpydates): add comprehensive docstrings for NumpyDates types
Add module docstring and detailed docs for Unit enum and datetime/ timedelta types (DateTime64, InlineDateTime64, TimeDelta64, InlineTimeDelta64), including accepted constructor inputs and unit references. Document supertypes AbstractDateTime64 and AbstractTimeDelta64. No functional changes.
1 parent a461e3b commit be62b3d

File tree

8 files changed

+59
-4
lines changed

8 files changed

+59
-4
lines changed

src/NumpyDates/AbstractDateTime64.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
"""
2+
abstract type AbstractDateTime64 <: Dates.TimeType
3+
4+
Supertype for [`DateTime64`](@ref) and [`InlineDateTime64`](@ref).
5+
"""
16
abstract type AbstractDateTime64 <: Dates.TimeType end
27

38
function Dates.value(d::AbstractDateTime64)

src/NumpyDates/AbstractTimeDelta64.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
"""
2+
abstract type AbstractTimeDelta64 <: Dates.Period
3+
4+
Supertype for [`TimeDelta64`](@ref) and [`InlineTimeDelta64`](@ref).
5+
"""
16
abstract type AbstractTimeDelta64 <: Dates.Period end
27

38
function Base.isnan(d::AbstractTimeDelta64)

src/NumpyDates/DateTime64.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@
44
DateTime64(value, [unit])
55
DateTime64(value, format, [unit])
66
7-
Construct an `DateTime64` with the given value and unit.
7+
Construct an `DateTime64` with the given `value` and [`unit`](@ref Unit).
8+
9+
The value can be:
10+
- An `Integer`, in which case the `unit` is required.
11+
- A `Dates.Date` or `Dates.DateTime`.
12+
- `"NaT"` or `"NaN"` to make a not-a-time value.
13+
- An `AbstractString`, which is parsed the same as `Dates.DateTime`, with an optional
14+
`format` string.
815
"""
916
struct DateTime64 <: AbstractDateTime64
1017
value::Int64

src/NumpyDates/InlineDateTime64.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@
66
InlineDateTime64(value, [unit])
77
InlineDateTime64(value, format, [unit])
88
9-
Construct an `InlineDateTime64` with the given value and unit.
9+
Construct an `InlineDateTime64` with the given `value` and [`unit`](@ref Unit).
10+
11+
The `value` can be:
12+
- An `Integer`, in which case the `unit` is required.
13+
- A `Dates.Date` or `Dates.DateTime`.
14+
- `"NaT"` or `"NaN"` to make a not-a-time value.
15+
- An `AbstractString`, which is parsed the same as `Dates.DateTime`, with an optional
16+
`format` string.
1017
"""
1118
struct InlineDateTime64{U} <: AbstractDateTime64
1219
value::Int64

src/NumpyDates/InlineTimeDelta64.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
InlineTimeDelta64{unit}(value)
55
InlineTimeDelta64(value, [unit])
66
7-
Construct an `InlineTimeDelta64` with the given value and unit.
7+
Construct an `InlineTimeDelta64` with the given `value` and [`unit`](@ref Unit).
8+
9+
The value can be:
10+
- An `Integer`, in which case the `unit` is required.
11+
- `"NaT"` or `"NaN"` to make a not-a-time value.
812
"""
913
struct InlineTimeDelta64{U} <: AbstractTimeDelta64
1014
value::Int64

src/NumpyDates/NumpyDates.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
"""
2+
module NumpyDates
3+
4+
Provides datetimes and timedeltas compatible with Numpy.
5+
6+
See: [`DateTime64`](@ref), [`InlineDateTime64`](@ref), [`TimeDelta64`](@ref) and
7+
[`InlineTimeDelta64`](@ref).
8+
9+
These can generally be converted to/from their respective types in the `Dates` stdlib.
10+
"""
111
module NumpyDates
212

313
using Dates: Dates, value

src/NumpyDates/TimeDelta64.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
"""
44
TimeDelta64(value, [unit])
55
6-
Construct a `TimeDelta64` with the given value and unit.
6+
Construct a `TimeDelta64` with the given `value` and [`unit`](@ref Unit).
7+
8+
The value can be:
9+
- An `Integer`, in which case the `unit` is required.
10+
- `"NaT"` or `"NaN"` to make a not-a-time value.
711
"""
812
struct TimeDelta64 <: AbstractTimeDelta64
913
value::Int64

src/NumpyDates/Unit.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
"""
2+
@enum Unit
3+
4+
The possible time units for datetimes and timedeltas in this module.
5+
6+
Values are: `YEARS`, `MONTHS`, `WEEKS`, `DAYS`, `HOURS`, `MINUTES`, `SECONDS`,
7+
`MILLISECONDS`, `MICROSECONDS`, `NANOSECONDS`, `PICOSECONDS`, `FEMTOSECONDS`,
8+
`ATTOSECONDS`.
9+
10+
For compatibility with numpy, the types in this module also accept scaled units as a
11+
`Tuple{Unit,Int}`. For example `(MINUTES, 15)` for units of 15 minutes. This feature is
12+
rarely used.
13+
"""
114
@enum Unit::Cint begin
215
YEARS = 0
316
MONTHS = 1

0 commit comments

Comments
 (0)