Skip to content

Commit 1402e8d

Browse files
authored
Update duration docs for oldtime feature (#484)
The main crate docs made some claims about the Duration type that became incorrect with the new oldtime feature (#478). Per @jhpratt.
1 parent 70432bc commit 1402e8d

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

README.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,22 @@ See the [cargo docs][] for examples of specifying features.
7777

7878
### Duration
7979

80-
Chrono currently uses
81-
the [`time::Duration`](https://docs.rs/time/0.1.40/time/struct.Duration.html) type
82-
from the `time` crate to represent the magnitude of a time span.
83-
Since this has the same name as the newer, standard type for duration,
84-
the reference will refer this type as `OldDuration`.
80+
Chrono currently uses its own [`Duration`] type to represent the magnitude
81+
of a time span. Since this has the same name as the newer, standard type for
82+
duration, the reference will refer this type as `OldDuration`.
83+
8584
Note that this is an "accurate" duration represented as seconds and
8685
nanoseconds and does not represent "nominal" components such as days or
8786
months.
8887

88+
When the `oldtime` feature is enabled, [`Duration`] is an alias for the
89+
[`time::Duration`](https://docs.rs/time/0.1.40/time/struct.Duration.html)
90+
type from v0.1 of the time crate. time v0.1 is deprecated, so new code
91+
should disable the `oldtime` feature and use the `chrono::Duration` type
92+
instead. The `oldtime` feature is enabled by default for backwards
93+
compatibility, but future versions of Chrono are likely to remove the
94+
feature entirely.
95+
8996
Chrono does not yet natively support
9097
the standard [`Duration`](https://doc.rust-lang.org/std/time/struct.Duration.html) type,
9198
but it will be supported in the future.

src/lib.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,22 @@
6464
//!
6565
//! ### Duration
6666
//!
67-
//! Chrono currently uses
68-
//! the [`time::Duration`](https://docs.rs/time/0.1.40/time/struct.Duration.html) type
69-
//! from the `time` crate to represent the magnitude of a time span.
70-
//! Since this has the same name as the newer, standard type for duration,
71-
//! the reference will refer this type as `OldDuration`.
67+
//! Chrono currently uses its own [`Duration`] type to represent the magnitude
68+
//! of a time span. Since this has the same name as the newer, standard type for
69+
//! duration, the reference will refer this type as `OldDuration`.
70+
//!
7271
//! Note that this is an "accurate" duration represented as seconds and
7372
//! nanoseconds and does not represent "nominal" components such as days or
7473
//! months.
7574
//!
75+
//! When the `oldtime` feature is enabled, [`Duration`] is an alias for the
76+
//! [`time::Duration`](https://docs.rs/time/0.1.40/time/struct.Duration.html)
77+
//! type from v0.1 of the time crate. time v0.1 is deprecated, so new code
78+
//! should disable the `oldtime` feature and use the `chrono::Duration` type
79+
//! instead. The `oldtime` feature is enabled by default for backwards
80+
//! compatibility, but future versions of Chrono are likely to remove the
81+
//! feature entirely.
82+
//!
7683
//! Chrono does not yet natively support
7784
//! the standard [`Duration`](https://doc.rust-lang.org/std/time/struct.Duration.html) type,
7885
//! but it will be supported in the future.

0 commit comments

Comments
 (0)