Skip to content

Commit 1f4b093

Browse files
committed
better phrasing about periodic time
1 parent 4e5679b commit 1f4b093

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

stdlib/Dates/docs/src/index.md

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

77
The `Dates` module provides three types for representing dates and times:
8-
[`Date`](@ref), [`DateTime`](@ref), and [`Time`](@ref) representing
8+
[`Date`](@ref), [`DateTime`](@ref), and [`Time`](@ref) measured with
99
day, millisecond and nanosecond precision, respectively;
1010
all are subtypes of the abstract [`TimeType`](@ref).
1111
The motivation for distinct types is simple: some operations are much simpler, both in terms of
@@ -29,8 +29,10 @@ The ISO standard, however, states that 1 BC/BCE is year zero, so `0000-12-31` is
2929
BC/BCE, etc.
3030

3131
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.
32+
and represents the time of day according to the conventional 24-hour clock, starting at midnight,
33+
and ending the instant one nanosecond prior to midnight. Time is periodic, and wraps around at
34+
midnight (see [TimeType-Period arithmetic](#TimeType-Period-Arithmetic)).
35+
3436

3537
[^1]:
3638
The notion of the UT second is actually quite fundamental. There are basically two different notions
@@ -45,7 +47,7 @@ Note that midnight is represented as 0 hour. 24 hour is out of range.
4547

4648
## Constructors
4749

48-
[`Date`](@ref) and [`DateTime`](@ref) types can be constructed by integer or [`Period`](@ref)
50+
[`Date`](@ref), [`DateTime`](@ref) and [`Time`](@ref) types can be constructed by integer or [`Period`](@ref)
4951
types, by parsing, or through adjusters (more on those later):
5052

5153
```jldoctest
@@ -84,6 +86,16 @@ julia> Date(Dates.Year(2013),Dates.Month(7),Dates.Day(1))
8486
8587
julia> Date(Dates.Month(7),Dates.Year(2013))
8688
2013-07-01
89+
90+
julia> Time(12)
91+
12:00:00
92+
93+
julia> Time(12, 30, 59, 1, 0, 2)
94+
12:30:59.001000002
95+
96+
julia> Time(Hour(12), Minute(30), Second(59), Millisecond(1), Nanosecond(2))
97+
12:30:59.001000002
98+
8799
```
88100

89101
[`Date`](@ref) or [`DateTime`](@ref) parsing is accomplished by the use of format strings. Format
@@ -463,6 +475,13 @@ julia> collect(dr)
463475
2014-05-29
464476
2014-06-29
465477
2014-07-29
478+
```
479+
480+
Time is periodic, and wraps around at midnight:
481+
482+
```jldoctest
483+
julia> Time(23) + Hour(1)
484+
00:00:00
466485
467486
julia> r = range(Time(0), step = Hour(9), length = 5)
468487
Time(0):Hour(9):Time(12)

0 commit comments

Comments
 (0)