Skip to content

Commit b4fe696

Browse files
committed
fix Date Functions docs references; refresh doco for
1 parent abcb6c9 commit b4fe696

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

stdlib/Dates/docs/src/index.md

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
DocTestSetup = :(using Dates)
55
```
66

7-
The `Dates` module provides two types for working with dates: [`Date`](@ref) and [`DateTime`](@ref),
8-
representing day and millisecond precision, respectively; both are subtypes of the abstract [`TimeType`](@ref).
7+
The `Dates` module provides three types for representing dates and times:
8+
[`Date`](@ref), [`DateTime`](@ref), and [`Time`](@ref) representing
9+
day, millisecond and nanosecond precision, respectively;
10+
all are subtypes of the abstract [`TimeType`](@ref).
911
The motivation for distinct types is simple: some operations are much simpler, both in terms of
1012
code and mental reasoning, when the complexities of greater precision don't have to be dealt with.
1113
For example, since the [`Date`](@ref) type only resolves to the precision of a single date (i.e.
@@ -14,7 +16,7 @@ time, and leap seconds are unnecessary and avoided.
1416

1517
Both [`Date`](@ref) and [`DateTime`](@ref) are basically immutable [`Int64`](@ref) wrappers.
1618
The single `instant` field of either type is actually a `UTInstant{P}` type, which
17-
represents a continuously increasing machine timeline based on the UT second [^1]. The
19+
represents a monotonically increasing machine timeline based on the UT second [^1]. The
1820
[`DateTime`](@ref) type is not aware of time zones (*naive*, in Python parlance),
1921
analogous to a *LocalDateTime* in Java 8. Additional time zone functionality
2022
can be added through the [TimeZones.jl package](https://github.com/JuliaTime/TimeZones.jl/), which
@@ -26,6 +28,10 @@ The ISO standard, however, states that 1 BC/BCE is year zero, so `0000-12-31` is
2628
`0001-01-01`, and year `-0001` (yes, negative one for the year) is 2 BC/BCE, year `-0002` is 3
2729
BC/BCE, etc.
2830

31+
The [`Time`](@ref) is also an immutable [`Int64`](@ref) wrapper, also based on the UT second [^1],
32+
but constrained to represent the periodic (cyclic) time of the 24-hour day starting at midnight.
33+
Note that midnight is represented as 0 hour - 24 hour is out of range.
34+
2935
[^1]:
3036
The notion of the UT second is actually quite fundamental. There are basically two different notions
3137
of time generally accepted, one based on the physical rotation of the earth (one full rotation
@@ -457,6 +463,18 @@ julia> collect(dr)
457463
2014-05-29
458464
2014-06-29
459465
2014-07-29
466+
467+
julia> r = range(Time(0), step = Hour(9), length = 5)
468+
Time(0):Hour(9):Time(12)
469+
470+
julia> collect(r)
471+
5-element Vector{Time}:
472+
00:00:00
473+
09:00:00
474+
18:00:00
475+
03:00:00
476+
12:00:00
477+
460478
```
461479

462480
## Adjuster Functions
@@ -707,7 +725,7 @@ Dates.UTC
707725
Dates.DateTime(::Int64, ::Int64, ::Int64, ::Int64, ::Int64, ::Int64, ::Int64)
708726
Dates.DateTime(::Dates.Period)
709727
Dates.DateTime(::Function, ::Any...)
710-
Dates.DateTime(::Dates.TimeType)
728+
Dates.DateTime(::Dates.Date)
711729
Dates.DateTime(::AbstractString, ::AbstractString)
712730
Dates.format(::Dates.TimeType, ::AbstractString)
713731
Dates.DateFormat
@@ -716,7 +734,7 @@ Dates.DateTime(::AbstractString, ::Dates.DateFormat)
716734
Dates.Date(::Int64, ::Int64, ::Int64)
717735
Dates.Date(::Dates.Period)
718736
Dates.Date(::Function, ::Any, ::Any, ::Any)
719-
Dates.Date(::Dates.TimeType)
737+
Dates.Date(::Dates.DateTime)
720738
Dates.Date(::AbstractString, ::AbstractString)
721739
Dates.Date(::AbstractString, ::Dates.DateFormat)
722740
Dates.Time(::Int64::Int64, ::Int64, ::Int64, ::Int64, ::Int64)

stdlib/Dates/src/types.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ struct UTC <: TimeZone end
132132
"""
133133
TimeType
134134
135-
`TimeType` types wrap `Instant` machine instances to provide human representations of the
135+
`TimeType` types wrap `Instant` machine instants to provide human representations of the
136136
machine instant. `Time`, `DateTime` and `Date` are subtypes of `TimeType`.
137137
"""
138138
abstract type TimeType <: AbstractTime end

0 commit comments

Comments
 (0)