| <!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="ISO 8601 time duration with nanosecond precision."><meta name="keywords" content="rust, rustlang, rust-lang, Duration"><title>Duration in chrono - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" href="../normalize.css"><link rel="stylesheet" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" href="../ayu.css" disabled><link rel="stylesheet" href="../dark.css" disabled><link rel="stylesheet" href="../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../storage.js"></script><script defer src="sidebar-items.js"></script><script defer src="../main.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../favicon.svg"></head><body class="rustdoc struct"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button><a class="sidebar-logo" href="../chrono/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><h2></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../chrono/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">Duration</a></h2><div class="sidebar-elems"><section><h3><a href="#implementations">Methods</a></h3><ul class="block"><li><a href="#method.abs">abs</a></li><li><a href="#method.checked_add">checked_add</a></li><li><a href="#method.checked_sub">checked_sub</a></li><li><a href="#method.days">days</a></li><li><a href="#method.from_std">from_std</a></li><li><a href="#method.hours">hours</a></li><li><a href="#method.is_zero">is_zero</a></li><li><a href="#method.max_value">max_value</a></li><li><a href="#method.microseconds">microseconds</a></li><li><a href="#method.milliseconds">milliseconds</a></li><li><a href="#method.min_value">min_value</a></li><li><a href="#method.minutes">minutes</a></li><li><a href="#method.nanoseconds">nanoseconds</a></li><li><a href="#method.num_days">num_days</a></li><li><a href="#method.num_hours">num_hours</a></li><li><a href="#method.num_microseconds">num_microseconds</a></li><li><a href="#method.num_milliseconds">num_milliseconds</a></li><li><a href="#method.num_minutes">num_minutes</a></li><li><a href="#method.num_nanoseconds">num_nanoseconds</a></li><li><a href="#method.num_seconds">num_seconds</a></li><li><a href="#method.num_weeks">num_weeks</a></li><li><a href="#method.seconds">seconds</a></li><li><a href="#method.to_std">to_std</a></li><li><a href="#method.weeks">weeks</a></li><li><a href="#method.zero">zero</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block"><li><a href="#impl-Add%3CDuration%3E-for-Date%3CTz%3E">Add<Duration></a></li><li><a href="#impl-Add%3CDuration%3E-for-DateTime%3CTz%3E">Add<Duration></a></li><li><a href="#impl-Add%3CDuration%3E-for-Duration">Add<Duration></a></li><li><a href="#impl-Add%3CDuration%3E-for-NaiveDate">Add<Duration></a></li><li><a href="#impl-Add%3CDuration%3E-for-NaiveDateTime">Add<Duration></a></li><li><a href="#impl-Add%3CDuration%3E-for-NaiveTime">Add<Duration></a></li><li><a href="#impl-AddAssign%3CDuration%3E-for-Date%3CTz%3E">AddAssign<Duration></a></li><li><a href="#impl-AddAssign%3CDuration%3E-for-DateTime%3CTz%3E">AddAssign<Duration></a></li><li><a href="#impl-AddAssign%3CDuration%3E-for-NaiveDate">AddAssign<Duration></a></li><li><a href="#impl-AddAssign%3CDuration%3E-for-NaiveDateTime">AddAssign<Duration></a></li><li><a href="#impl-AddAssign%3CDuration%3E-for-NaiveTime">AddAssign<Duration></a></li><li><a href="#impl-Clone-for-Duration">Clone</a></li><li><a href="#impl-Copy-for-Duration">Copy</a></li><li><a href="#impl-Debug-for-Duration">Debug</a></li><li><a href="#impl-Display-for-Duration">Display</a></li><li><a href="#impl-Div%3Ci32%3E-for-Duration">Div<i32></a></li><li><a href="#impl-Eq-for-Duration">Eq</a></li><li><a href="#impl-Hash-for-Duration">Hash</a></li><li><a href="#impl-Mul%3Ci32%3E-for-Duration">Mul<i32></a></li><li><a href="#impl-Neg-for-Duration">Neg</a></li><li><a href="#impl-Ord-for-Duration">Ord</a></li><li><a href="#impl-PartialEq%3CDuration%3E-for-Duration">PartialEq<Duration></a></li><li><a href="#impl-PartialOrd%3CDuration%3E-for-Duration">PartialOrd<Duration></a></li><li><a href="#impl-StructuralEq-for-Duration">StructuralEq</a></li><li><a href="#impl-StructuralPartialEq-for-Duration">StructuralPartialEq</a></li><li><a href="#impl-Sub%3CDuration%3E-for-Date%3CTz%3E">Sub<Duration></a></li><li><a href="#impl-Sub%3CDuration%3E-for-DateTime%3CTz%3E">Sub<Duration></a></li><li><a href="#impl-Sub%3CDuration%3E-for-Duration">Sub<Duration></a></li><li><a href="#impl-Sub%3CDuration%3E-for-NaiveDate">Sub<Duration></a></li><li><a href="#impl-Sub%3CDuration%3E-for-NaiveDateTime">Sub<Duration></a></li><li><a href="#impl-Sub%3CDuration%3E-for-NaiveTime">Sub<Duration></a></li><li><a href="#impl-SubAssign%3CDuration%3E-for-Date%3CTz%3E">SubAssign<Duration></a></li><li><a href="#impl-SubAssign%3CDuration%3E-for-DateTime%3CTz%3E">SubAssign<Duration></a></li><li><a href="#impl-SubAssign%3CDuration%3E-for-NaiveDate">SubAssign<Duration></a></li><li><a href="#impl-SubAssign%3CDuration%3E-for-NaiveDateTime">SubAssign<Duration></a></li><li><a href="#impl-SubAssign%3CDuration%3E-for-NaiveTime">SubAssign<Duration></a></li><li><a href="#impl-Sum%3C%26%27a%20Duration%3E-for-Duration">Sum<&'a Duration></a></li><li><a href="#impl-Sum%3CDuration%3E-for-Duration">Sum<Duration></a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block"><li><a href="#impl-RefUnwindSafe-for-Duration">RefUnwindSafe</a></li><li><a href="#impl-Send-for-Duration">Send</a></li><li><a href="#impl-Sync-for-Duration">Sync</a></li><li><a href="#impl-Unpin-for-Duration">Unpin</a></li><li><a href="#impl-UnwindSafe-for-Duration">UnwindSafe</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block"><li><a href="#impl-Any-for-Duration">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-Duration">Borrow<T></a></li><li><a href="#impl-BorrowMut%3CT%3E-for-Duration">BorrowMut<T></a></li><li><a href="#impl-From%3CT%3E-for-Duration">From<T></a></li><li><a href="#impl-Into%3CU%3E-for-Duration">Into<U></a></li><li><a href="#impl-ToOwned-for-Duration">ToOwned</a></li><li><a href="#impl-ToString-for-Duration">ToString</a></li><li><a href="#impl-TryFrom%3CU%3E-for-Duration">TryFrom<U></a></li><li><a href="#impl-TryInto%3CU%3E-for-Duration">TryInto<U></a></li></ul></section><h2><a href="index.html">In chrono</a></h2></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../wheel.svg"></a></div></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn">Struct <a href="index.html">chrono</a>::<wbr><a class="struct" href="#">Duration</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../clipboard.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="srclink" href="../src/chrono/oldtime.rs.html#55-58">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span></div><div class="item-decl"><pre class="rust struct"><code>pub struct Duration { /* private fields */ }</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>ISO 8601 time duration with nanosecond precision.</p> |
| <p>This also allows for the negative duration; see individual methods for details.</p> |
| </div></details><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><div id="implementations-list"><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Duration" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#72-316">source</a><a href="#impl-Duration" class="anchor"></a><h3 class="code-header">impl <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.weeks" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#78-81">source</a><h4 class="code-header">pub fn <a href="#method.weeks" class="fnname">weeks</a>(weeks: i64) -> <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h4></section></summary><div class="docblock"><p>Makes a new <code>Duration</code> with given number of weeks. |
| Equivalent to <code>Duration::seconds(weeks * 7 * 24 * 60 * 60)</code> with overflow checks. |
| Panics when the duration is out of bounds.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.days" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#88-91">source</a><h4 class="code-header">pub fn <a href="#method.days" class="fnname">days</a>(days: i64) -> <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h4></section></summary><div class="docblock"><p>Makes a new <code>Duration</code> with given number of days. |
| Equivalent to <code>Duration::seconds(days * 24 * 60 * 60)</code> with overflow checks. |
| Panics when the duration is out of bounds.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.hours" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#98-101">source</a><h4 class="code-header">pub fn <a href="#method.hours" class="fnname">hours</a>(hours: i64) -> <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h4></section></summary><div class="docblock"><p>Makes a new <code>Duration</code> with given number of hours. |
| Equivalent to <code>Duration::seconds(hours * 60 * 60)</code> with overflow checks. |
| Panics when the duration is out of bounds.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.minutes" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#108-111">source</a><h4 class="code-header">pub fn <a href="#method.minutes" class="fnname">minutes</a>(minutes: i64) -> <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h4></section></summary><div class="docblock"><p>Makes a new <code>Duration</code> with given number of minutes. |
| Equivalent to <code>Duration::seconds(minutes * 60)</code> with overflow checks. |
| Panics when the duration is out of bounds.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.seconds" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#118-124">source</a><h4 class="code-header">pub fn <a href="#method.seconds" class="fnname">seconds</a>(seconds: i64) -> <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h4></section></summary><div class="docblock"><p>Makes a new <code>Duration</code> with given number of seconds. |
| Panics when the duration is more than <code>i64::MAX</code> seconds |
| or less than <code>i64::MIN</code> seconds.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.milliseconds" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#128-132">source</a><h4 class="code-header">pub const fn <a href="#method.milliseconds" class="fnname">milliseconds</a>(milliseconds: i64) -> <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h4></section></summary><div class="docblock"><p>Makes a new <code>Duration</code> with given number of milliseconds.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.microseconds" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#136-140">source</a><h4 class="code-header">pub const fn <a href="#method.microseconds" class="fnname">microseconds</a>(microseconds: i64) -> <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h4></section></summary><div class="docblock"><p>Makes a new <code>Duration</code> with given number of microseconds.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.nanoseconds" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#144-147">source</a><h4 class="code-header">pub const fn <a href="#method.nanoseconds" class="fnname">nanoseconds</a>(nanos: i64) -> <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h4></section></summary><div class="docblock"><p>Makes a new <code>Duration</code> with given number of nanoseconds.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.num_weeks" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#151-153">source</a><h4 class="code-header">pub const fn <a href="#method.num_weeks" class="fnname">num_weeks</a>(&self) -> i64</h4></section></summary><div class="docblock"><p>Returns the total number of whole weeks in the duration.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.num_days" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#156-158">source</a><h4 class="code-header">pub const fn <a href="#method.num_days" class="fnname">num_days</a>(&self) -> i64</h4></section></summary><div class="docblock"><p>Returns the total number of whole days in the duration.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.num_hours" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#162-164">source</a><h4 class="code-header">pub const fn <a href="#method.num_hours" class="fnname">num_hours</a>(&self) -> i64</h4></section></summary><div class="docblock"><p>Returns the total number of whole hours in the duration.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.num_minutes" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#168-170">source</a><h4 class="code-header">pub const fn <a href="#method.num_minutes" class="fnname">num_minutes</a>(&self) -> i64</h4></section></summary><div class="docblock"><p>Returns the total number of whole minutes in the duration.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.num_seconds" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#173-180">source</a><h4 class="code-header">pub const fn <a href="#method.num_seconds" class="fnname">num_seconds</a>(&self) -> i64</h4></section></summary><div class="docblock"><p>Returns the total number of whole seconds in the duration.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.num_milliseconds" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#194-200">source</a><h4 class="code-header">pub const fn <a href="#method.num_milliseconds" class="fnname">num_milliseconds</a>(&self) -> i64</h4></section></summary><div class="docblock"><p>Returns the total number of whole milliseconds in the duration,</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.num_microseconds" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#204-208">source</a><h4 class="code-header">pub const fn <a href="#method.num_microseconds" class="fnname">num_microseconds</a>(&self) -> Option<i64></h4></section></summary><div class="docblock"><p>Returns the total number of whole microseconds in the duration, |
| or <code>None</code> on overflow (exceeding 2^63 microseconds in either direction).</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.num_nanoseconds" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#212-216">source</a><h4 class="code-header">pub const fn <a href="#method.num_nanoseconds" class="fnname">num_nanoseconds</a>(&self) -> Option<i64></h4></section></summary><div class="docblock"><p>Returns the total number of whole nanoseconds in the duration, |
| or <code>None</code> on overflow (exceeding 2^63 nanoseconds in either direction).</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.checked_add" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#220-235">source</a><h4 class="code-header">pub fn <a href="#method.checked_add" class="fnname">checked_add</a>(&self, rhs: &<a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>) -> Option<<a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>></h4></section></summary><div class="docblock"><p>Add two durations, returning <code>None</code> if overflow occurred.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.checked_sub" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#239-254">source</a><h4 class="code-header">pub fn <a href="#method.checked_sub" class="fnname">checked_sub</a>(&self, rhs: &<a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>) -> Option<<a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>></h4></section></summary><div class="docblock"><p>Subtract two durations, returning <code>None</code> if overflow occurred.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.abs" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#258-264">source</a><h4 class="code-header">pub const fn <a href="#method.abs" class="fnname">abs</a>(&self) -> <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h4></section></summary><div class="docblock"><p>Returns the duration as an absolute (non-negative) value.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.min_value" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#268-270">source</a><h4 class="code-header">pub const fn <a href="#method.min_value" class="fnname">min_value</a>() -> <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h4></section></summary><div class="docblock"><p>The minimum possible <code>Duration</code>: <code>i64::MIN</code> milliseconds.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.max_value" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#274-276">source</a><h4 class="code-header">pub const fn <a href="#method.max_value" class="fnname">max_value</a>() -> <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h4></section></summary><div class="docblock"><p>The maximum possible <code>Duration</code>: <code>i64::MAX</code> milliseconds.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.zero" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#280-282">source</a><h4 class="code-header">pub const fn <a href="#method.zero" class="fnname">zero</a>() -> <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h4></section></summary><div class="docblock"><p>A duration where the stored seconds and nanoseconds are equal to zero.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.is_zero" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#286-288">source</a><h4 class="code-header">pub const fn <a href="#method.is_zero" class="fnname">is_zero</a>(&self) -> bool</h4></section></summary><div class="docblock"><p>Returns <code>true</code> if the duration equals <code>Duration::zero()</code>.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from_std" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#294-304">source</a><h4 class="code-header">pub fn <a href="#method.from_std" class="fnname">from_std</a>(duration: StdDuration) -> Result<<a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>, <a class="struct" href="struct.OutOfRangeError.html" title="struct chrono::OutOfRangeError">OutOfRangeError</a>></h4></section></summary><div class="docblock"><p>Creates a <code>time::Duration</code> object from <code>std::time::Duration</code></p> |
| <p>This function errors when original duration is larger than the maximum |
| value supported for this type.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.to_std" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#310-315">source</a><h4 class="code-header">pub fn <a href="#method.to_std" class="fnname">to_std</a>(&self) -> Result<StdDuration, <a class="struct" href="struct.OutOfRangeError.html" title="struct chrono::OutOfRangeError">OutOfRangeError</a>></h4></section></summary><div class="docblock"><p>Creates a <code>std::time::Duration</code> object from <code>time::Duration</code></p> |
| <p>This function errors when duration is less than zero. As standard |
| library implementation is limited to non-negative values.</p> |
| </div></details></div></details></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Add%3CDuration%3E-for-Date%3CTz%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/date.rs.html#504-511">source</a><a href="#impl-Add%3CDuration%3E-for-Date%3CTz%3E" class="anchor"></a><h3 class="code-header">impl<Tz: <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>> Add<<a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>> for <a class="struct" href="struct.Date.html" title="struct chrono::Date">Date</a><Tz></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Output-5" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Output-5" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Output</a> = <a class="struct" href="struct.Date.html" title="struct chrono::Date">Date</a><Tz></h4></section></summary><div class='docblock'>The resulting type after applying the <code>+</code> operator.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.add-1" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/date.rs.html#508-510">source</a><a href="#method.add-1" class="anchor"></a><h4 class="code-header">fn <a class="fnname">add</a>(self, rhs: <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">OldDuration</a>) -> <a class="struct" href="struct.Date.html" title="struct chrono::Date">Date</a><Tz></h4></section></summary><div class='docblock'>Performs the <code>+</code> operation. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Add%3CDuration%3E-for-DateTime%3CTz%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#986-993">source</a><a href="#impl-Add%3CDuration%3E-for-DateTime%3CTz%3E" class="anchor"></a><h3 class="code-header">impl<Tz: <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>> Add<<a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>> for <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Output-7" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Output-7" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Output</a> = <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h4></section></summary><div class='docblock'>The resulting type after applying the <code>+</code> operator.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.add-2" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#990-992">source</a><a href="#method.add-2" class="anchor"></a><h4 class="code-header">fn <a class="fnname">add</a>(self, rhs: <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">OldDuration</a>) -> <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h4></section></summary><div class='docblock'>Performs the <code>+</code> operation. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Add%3CDuration%3E-for-Duration" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#331-343">source</a><a href="#impl-Add%3CDuration%3E-for-Duration" class="anchor"></a><h3 class="code-header">impl Add<<a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>> for <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Output-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Output-1" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Output</a> = <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h4></section></summary><div class='docblock'>The resulting type after applying the <code>+</code> operator.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.add" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#334-342">source</a><a href="#method.add" class="anchor"></a><h4 class="code-header">fn <a class="fnname">add</a>(self, rhs: <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>) -> <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h4></section></summary><div class='docblock'>Performs the <code>+</code> operation. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Add%3CDuration%3E-for-NaiveDate" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/naive/date.rs.html#1728-1735">source</a><a href="#impl-Add%3CDuration%3E-for-NaiveDate" class="anchor"></a><h3 class="code-header">impl Add<<a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>> for <a class="struct" href="naive/struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h3></section></summary><div class="docblock"><p>An addition of <code>Duration</code> to <code>NaiveDate</code> discards the fractional days, |
| rounding to the closest integral number of days towards <code>Duration::zero()</code>.</p> |
| <p>Panics on underflow or overflow. Use <a href="naive/struct.NaiveDate.html#method.checked_add_signed"><code>NaiveDate::checked_add_signed</code></a> to detect that.</p> |
| <h4 id="example"><a href="#example">Example</a></h4> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{Duration, NaiveDate}; |
| |
| <span class="kw">let </span>from_ymd = |y, m, d| NaiveDate::from_ymd_opt(y, m, d).unwrap(); |
| |
| <span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) + Duration::zero(), from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>)); |
| <span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) + Duration::seconds(<span class="number">86399</span>), from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>)); |
| <span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) + Duration::seconds(-<span class="number">86399</span>), from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>)); |
| <span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) + Duration::days(<span class="number">1</span>), from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">2</span>)); |
| <span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) + Duration::days(-<span class="number">1</span>), from_ymd(<span class="number">2013</span>, <span class="number">12</span>, <span class="number">31</span>)); |
| <span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) + Duration::days(<span class="number">364</span>), from_ymd(<span class="number">2014</span>, <span class="number">12</span>, <span class="number">31</span>)); |
| <span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) + Duration::days(<span class="number">365</span><span class="kw-2">*</span><span class="number">4 </span>+ <span class="number">1</span>), from_ymd(<span class="number">2018</span>, <span class="number">1</span>, <span class="number">1</span>)); |
| <span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) + Duration::days(<span class="number">365</span><span class="kw-2">*</span><span class="number">400 </span>+ <span class="number">97</span>), from_ymd(<span class="number">2414</span>, <span class="number">1</span>, <span class="number">1</span>));</code></pre></div> |
| </div><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Output-9" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Output-9" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Output</a> = <a class="struct" href="naive/struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h4></section></summary><div class='docblock'>The resulting type after applying the <code>+</code> operator.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.add-3" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/naive/date.rs.html#1732-1734">source</a><a href="#method.add-3" class="anchor"></a><h4 class="code-header">fn <a class="fnname">add</a>(self, rhs: <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">OldDuration</a>) -> <a class="struct" href="naive/struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h4></section></summary><div class='docblock'>Performs the <code>+</code> operation. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Add%3CDuration%3E-for-NaiveDateTime" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/naive/datetime/mod.rs.html#1468-1475">source</a><a href="#impl-Add%3CDuration%3E-for-NaiveDateTime" class="anchor"></a><h3 class="code-header">impl Add<<a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>> for <a class="struct" href="naive/struct.NaiveDateTime.html" title="struct chrono::naive::NaiveDateTime">NaiveDateTime</a></h3></section></summary><div class="docblock"><p>An addition of <code>Duration</code> to <code>NaiveDateTime</code> yields another <code>NaiveDateTime</code>.</p> |
| <p>As a part of Chrono’s <a href="naive/struct.NaiveTime.html#leap-second-handling">leap second handling</a>, the addition assumes that <strong>there is no leap |
| second ever</strong>, except when the <code>NaiveDateTime</code> itself represents a leap second in which case |
| the assumption becomes that <strong>there is exactly a single leap second ever</strong>.</p> |
| <p>Panics on underflow or overflow. Use <a href="naive/struct.NaiveDateTime.html#method.checked_add_signed" title="NaiveDateTime::checked_add_signed"><code>NaiveDateTime::checked_add_signed</code></a> |
| to detect that.</p> |
| <h4 id="example-2"><a href="#example-2">Example</a></h4> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{Duration, NaiveDate}; |
| |
| <span class="kw">let </span>from_ymd = |y, m, d| NaiveDate::from_ymd_opt(y, m, d).unwrap(); |
| |
| <span class="kw">let </span>d = from_ymd(<span class="number">2016</span>, <span class="number">7</span>, <span class="number">8</span>); |
| <span class="kw">let </span>hms = |h, m, s| d.and_hms_opt(h, m, s).unwrap(); |
| <span class="macro">assert_eq!</span>(hms(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>) + Duration::zero(), hms(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>)); |
| <span class="macro">assert_eq!</span>(hms(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>) + Duration::seconds(<span class="number">1</span>), hms(<span class="number">3</span>, <span class="number">5</span>, <span class="number">8</span>)); |
| <span class="macro">assert_eq!</span>(hms(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>) + Duration::seconds(-<span class="number">1</span>), hms(<span class="number">3</span>, <span class="number">5</span>, <span class="number">6</span>)); |
| <span class="macro">assert_eq!</span>(hms(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>) + Duration::seconds(<span class="number">3600 </span>+ <span class="number">60</span>), hms(<span class="number">4</span>, <span class="number">6</span>, <span class="number">7</span>)); |
| <span class="macro">assert_eq!</span>(hms(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>) + Duration::seconds(<span class="number">86_400</span>), |
| from_ymd(<span class="number">2016</span>, <span class="number">7</span>, <span class="number">9</span>).and_hms_opt(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>).unwrap()); |
| <span class="macro">assert_eq!</span>(hms(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>) + Duration::days(<span class="number">365</span>), |
| from_ymd(<span class="number">2017</span>, <span class="number">7</span>, <span class="number">8</span>).and_hms_opt(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>).unwrap()); |
| |
| <span class="kw">let </span>hmsm = |h, m, s, milli| d.and_hms_milli_opt(h, m, s, milli).unwrap(); |
| <span class="macro">assert_eq!</span>(hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">980</span>) + Duration::milliseconds(<span class="number">450</span>), hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">8</span>, <span class="number">430</span>));</code></pre></div> |
| <p>Leap seconds are handled, |
| but the addition assumes that it is the only leap second happened.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>leap = hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">59</span>, <span class="number">1_300</span>); |
| <span class="macro">assert_eq!</span>(leap + Duration::zero(), hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">59</span>, <span class="number">1_300</span>)); |
| <span class="macro">assert_eq!</span>(leap + Duration::milliseconds(-<span class="number">500</span>), hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">59</span>, <span class="number">800</span>)); |
| <span class="macro">assert_eq!</span>(leap + Duration::milliseconds(<span class="number">500</span>), hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">59</span>, <span class="number">1_800</span>)); |
| <span class="macro">assert_eq!</span>(leap + Duration::milliseconds(<span class="number">800</span>), hmsm(<span class="number">3</span>, <span class="number">6</span>, <span class="number">0</span>, <span class="number">100</span>)); |
| <span class="macro">assert_eq!</span>(leap + Duration::seconds(<span class="number">10</span>), hmsm(<span class="number">3</span>, <span class="number">6</span>, <span class="number">9</span>, <span class="number">300</span>)); |
| <span class="macro">assert_eq!</span>(leap + Duration::seconds(-<span class="number">10</span>), hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">50</span>, <span class="number">300</span>)); |
| <span class="macro">assert_eq!</span>(leap + Duration::days(<span class="number">1</span>), |
| from_ymd(<span class="number">2016</span>, <span class="number">7</span>, <span class="number">9</span>).and_hms_milli_opt(<span class="number">3</span>, <span class="number">5</span>, <span class="number">59</span>, <span class="number">300</span>).unwrap());</code></pre></div> |
| </div><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Output-11" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Output-11" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Output</a> = <a class="struct" href="naive/struct.NaiveDateTime.html" title="struct chrono::naive::NaiveDateTime">NaiveDateTime</a></h4></section></summary><div class='docblock'>The resulting type after applying the <code>+</code> operator.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.add-4" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/naive/datetime/mod.rs.html#1472-1474">source</a><a href="#method.add-4" class="anchor"></a><h4 class="code-header">fn <a class="fnname">add</a>(self, rhs: <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">OldDuration</a>) -> <a class="struct" href="naive/struct.NaiveDateTime.html" title="struct chrono::naive::NaiveDateTime">NaiveDateTime</a></h4></section></summary><div class='docblock'>Performs the <code>+</code> operation. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Add%3CDuration%3E-for-NaiveTime" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/naive/time/mod.rs.html#1061-1068">source</a><a href="#impl-Add%3CDuration%3E-for-NaiveTime" class="anchor"></a><h3 class="code-header">impl Add<<a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>> for <a class="struct" href="naive/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a></h3></section></summary><div class="docblock"><p>An addition of <code>Duration</code> to <code>NaiveTime</code> wraps around and never overflows or underflows. |
| In particular the addition ignores integral number of days.</p> |
| <p>As a part of Chrono’s <a href="naive/struct.NaiveTime.html#leap-second-handling">leap second handling</a>, the addition assumes that <strong>there is no leap |
| second ever</strong>, except when the <code>NaiveTime</code> itself represents a leap second in which case the |
| assumption becomes that <strong>there is exactly a single leap second ever</strong>.</p> |
| <h4 id="example-4"><a href="#example-4">Example</a></h4> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{Duration, NaiveTime}; |
| |
| <span class="kw">let </span>from_hmsm = |h, m, s, milli| { NaiveTime::from_hms_milli_opt(h, m, s, milli).unwrap() }; |
| |
| <span class="macro">assert_eq!</span>(from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) + Duration::zero(), from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>)); |
| <span class="macro">assert_eq!</span>(from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) + Duration::seconds(<span class="number">1</span>), from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">8</span>, <span class="number">0</span>)); |
| <span class="macro">assert_eq!</span>(from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) + Duration::seconds(-<span class="number">1</span>), from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">0</span>)); |
| <span class="macro">assert_eq!</span>(from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) + Duration::seconds(<span class="number">60 </span>+ <span class="number">4</span>), from_hmsm(<span class="number">3</span>, <span class="number">6</span>, <span class="number">11</span>, <span class="number">0</span>)); |
| <span class="macro">assert_eq!</span>(from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) + Duration::seconds(<span class="number">7</span><span class="kw-2">*</span><span class="number">60</span><span class="kw-2">*</span><span class="number">60 </span>- <span class="number">6</span><span class="kw-2">*</span><span class="number">60</span>), from_hmsm(<span class="number">9</span>, <span class="number">59</span>, <span class="number">7</span>, <span class="number">0</span>)); |
| <span class="macro">assert_eq!</span>(from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) + Duration::milliseconds(<span class="number">80</span>), from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">80</span>)); |
| <span class="macro">assert_eq!</span>(from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">950</span>) + Duration::milliseconds(<span class="number">280</span>), from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">8</span>, <span class="number">230</span>)); |
| <span class="macro">assert_eq!</span>(from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">950</span>) + Duration::milliseconds(-<span class="number">980</span>), from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">970</span>));</code></pre></div> |
| <p>The addition wraps around.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) + Duration::seconds(<span class="number">22</span><span class="kw-2">*</span><span class="number">60</span><span class="kw-2">*</span><span class="number">60</span>), from_hmsm(<span class="number">1</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>)); |
| <span class="macro">assert_eq!</span>(from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) + Duration::seconds(-<span class="number">8</span><span class="kw-2">*</span><span class="number">60</span><span class="kw-2">*</span><span class="number">60</span>), from_hmsm(<span class="number">19</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>)); |
| <span class="macro">assert_eq!</span>(from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) + Duration::days(<span class="number">800</span>), from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>));</code></pre></div> |
| <p>Leap seconds are handled, but the addition assumes that it is the only leap second happened.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>leap = from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">59</span>, <span class="number">1_300</span>); |
| <span class="macro">assert_eq!</span>(leap + Duration::zero(), from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">59</span>, <span class="number">1_300</span>)); |
| <span class="macro">assert_eq!</span>(leap + Duration::milliseconds(-<span class="number">500</span>), from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">59</span>, <span class="number">800</span>)); |
| <span class="macro">assert_eq!</span>(leap + Duration::milliseconds(<span class="number">500</span>), from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">59</span>, <span class="number">1_800</span>)); |
| <span class="macro">assert_eq!</span>(leap + Duration::milliseconds(<span class="number">800</span>), from_hmsm(<span class="number">3</span>, <span class="number">6</span>, <span class="number">0</span>, <span class="number">100</span>)); |
| <span class="macro">assert_eq!</span>(leap + Duration::seconds(<span class="number">10</span>), from_hmsm(<span class="number">3</span>, <span class="number">6</span>, <span class="number">9</span>, <span class="number">300</span>)); |
| <span class="macro">assert_eq!</span>(leap + Duration::seconds(-<span class="number">10</span>), from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">50</span>, <span class="number">300</span>)); |
| <span class="macro">assert_eq!</span>(leap + Duration::days(<span class="number">1</span>), from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">59</span>, <span class="number">300</span>));</code></pre></div> |
| </div><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Output-13" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Output-13" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Output</a> = <a class="struct" href="naive/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a></h4></section></summary><div class='docblock'>The resulting type after applying the <code>+</code> operator.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.add-5" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/naive/time/mod.rs.html#1065-1067">source</a><a href="#method.add-5" class="anchor"></a><h4 class="code-header">fn <a class="fnname">add</a>(self, rhs: <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">OldDuration</a>) -> <a class="struct" href="naive/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a></h4></section></summary><div class='docblock'>Performs the <code>+</code> operation. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-AddAssign%3CDuration%3E-for-Date%3CTz%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/date.rs.html#513-518">source</a><a href="#impl-AddAssign%3CDuration%3E-for-Date%3CTz%3E" class="anchor"></a><h3 class="code-header">impl<Tz: <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>> AddAssign<<a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>> for <a class="struct" href="struct.Date.html" title="struct chrono::Date">Date</a><Tz></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.add_assign" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/date.rs.html#515-517">source</a><a href="#method.add_assign" class="anchor"></a><h4 class="code-header">fn <a class="fnname">add_assign</a>(&mut self, rhs: <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">OldDuration</a>)</h4></section></summary><div class='docblock'>Performs the <code>+=</code> operation. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-AddAssign%3CDuration%3E-for-DateTime%3CTz%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#995-1003">source</a><a href="#impl-AddAssign%3CDuration%3E-for-DateTime%3CTz%3E" class="anchor"></a><h3 class="code-header">impl<Tz: <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>> AddAssign<<a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>> for <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.add_assign-1" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#997-1002">source</a><a href="#method.add_assign-1" class="anchor"></a><h4 class="code-header">fn <a class="fnname">add_assign</a>(&mut self, rhs: <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">OldDuration</a>)</h4></section></summary><div class='docblock'>Performs the <code>+=</code> operation. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-AddAssign%3CDuration%3E-for-NaiveDate" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/naive/date.rs.html#1737-1742">source</a><a href="#impl-AddAssign%3CDuration%3E-for-NaiveDate" class="anchor"></a><h3 class="code-header">impl AddAssign<<a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>> for <a class="struct" href="naive/struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.add_assign-2" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/naive/date.rs.html#1739-1741">source</a><a href="#method.add_assign-2" class="anchor"></a><h4 class="code-header">fn <a class="fnname">add_assign</a>(&mut self, rhs: <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">OldDuration</a>)</h4></section></summary><div class='docblock'>Performs the <code>+=</code> operation. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-AddAssign%3CDuration%3E-for-NaiveDateTime" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/naive/datetime/mod.rs.html#1477-1482">source</a><a href="#impl-AddAssign%3CDuration%3E-for-NaiveDateTime" class="anchor"></a><h3 class="code-header">impl AddAssign<<a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>> for <a class="struct" href="naive/struct.NaiveDateTime.html" title="struct chrono::naive::NaiveDateTime">NaiveDateTime</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.add_assign-3" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/naive/datetime/mod.rs.html#1479-1481">source</a><a href="#method.add_assign-3" class="anchor"></a><h4 class="code-header">fn <a class="fnname">add_assign</a>(&mut self, rhs: <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">OldDuration</a>)</h4></section></summary><div class='docblock'>Performs the <code>+=</code> operation. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-AddAssign%3CDuration%3E-for-NaiveTime" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/naive/time/mod.rs.html#1070-1075">source</a><a href="#impl-AddAssign%3CDuration%3E-for-NaiveTime" class="anchor"></a><h3 class="code-header">impl AddAssign<<a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>> for <a class="struct" href="naive/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.add_assign-4" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/naive/time/mod.rs.html#1072-1074">source</a><a href="#method.add_assign-4" class="anchor"></a><h4 class="code-header">fn <a class="fnname">add_assign</a>(&mut self, rhs: <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">OldDuration</a>)</h4></section></summary><div class='docblock'>Performs the <code>+=</code> operation. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Clone-for-Duration" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#53">source</a><a href="#impl-Clone-for-Duration" class="anchor"></a><h3 class="code-header">impl Clone for <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.clone" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#53">source</a><a href="#method.clone" class="anchor"></a><h4 class="code-header">fn <a class="fnname">clone</a>(&self) -> <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h4></section></summary><div class='docblock'>Returns a copy of the value. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.clone_from" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.clone_from" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">clone_from</a>(&mut self, source: &Self)</h4></section></summary><div class='docblock'>Performs copy-assignment from <code>source</code>. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Debug-for-Duration" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#53">source</a><a href="#impl-Debug-for-Duration" class="anchor"></a><h3 class="code-header">impl Debug for <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.fmt" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#53">source</a><a href="#method.fmt" class="anchor"></a><h4 class="code-header">fn <a class="fnname">fmt</a>(&self, f: &mut Formatter<'_>) -> Result</h4></section></summary><div class='docblock'>Formats the value using the given formatter. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Display-for-Duration" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#407-439">source</a><a href="#impl-Display-for-Duration" class="anchor"></a><h3 class="code-header">impl Display for <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.fmt-1" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#411-438">source</a><a href="#method.fmt-1" class="anchor"></a><h4 class="code-header">fn <a class="fnname">fmt</a>(&self, f: &mut Formatter<'_>) -> Result</h4></section></summary><div class="docblock"><p>Format a duration using the <a href="https://en.wikipedia.org/wiki/ISO_8601#Durations">ISO 8601</a> format</p> |
| </div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Div%3Ci32%3E-for-Duration" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#371-389">source</a><a href="#impl-Div%3Ci32%3E-for-Duration" class="anchor"></a><h3 class="code-header">impl Div<i32> for <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Output-4" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Output-4" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Output</a> = <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h4></section></summary><div class='docblock'>The resulting type after applying the <code>/</code> operator.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.div" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#374-388">source</a><a href="#method.div" class="anchor"></a><h4 class="code-header">fn <a class="fnname">div</a>(self, rhs: i32) -> <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h4></section></summary><div class='docblock'>Performs the <code>/</code> operation. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Hash-for-Duration" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#53">source</a><a href="#impl-Hash-for-Duration" class="anchor"></a><h3 class="code-header">impl Hash for <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.hash" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#53">source</a><a href="#method.hash" class="anchor"></a><h4 class="code-header">fn <a class="fnname">hash</a><__H: Hasher>(&self, state: &mut __H)</h4></section></summary><div class='docblock'>Feeds this value into the given [<code>Hasher</code>]. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.hash_slice" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.3.0">1.3.0</span><a href="#method.hash_slice" class="anchor"></a><h4 class="code-header">fn <a class="fnname">hash_slice</a><H>(data: &[Self], state: &mut H)<span class="where fmt-newline">where<br> H: Hasher,</span></h4></section></summary><div class='docblock'>Feeds a slice of this type into the given [<code>Hasher</code>]. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Mul%3Ci32%3E-for-Duration" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#359-369">source</a><a href="#impl-Mul%3Ci32%3E-for-Duration" class="anchor"></a><h3 class="code-header">impl Mul<i32> for <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Output-3" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Output-3" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Output</a> = <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h4></section></summary><div class='docblock'>The resulting type after applying the <code>*</code> operator.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.mul" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#362-368">source</a><a href="#method.mul" class="anchor"></a><h4 class="code-header">fn <a class="fnname">mul</a>(self, rhs: i32) -> <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h4></section></summary><div class='docblock'>Performs the <code>*</code> operation. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Neg-for-Duration" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#318-329">source</a><a href="#impl-Neg-for-Duration" class="anchor"></a><h3 class="code-header">impl Neg for <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Output" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Output" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Output</a> = <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h4></section></summary><div class='docblock'>The resulting type after applying the <code>-</code> operator.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.neg" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#322-328">source</a><a href="#method.neg" class="anchor"></a><h4 class="code-header">fn <a class="fnname">neg</a>(self) -> <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h4></section></summary><div class='docblock'>Performs the unary <code>-</code> operation. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Ord-for-Duration" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#53">source</a><a href="#impl-Ord-for-Duration" class="anchor"></a><h3 class="code-header">impl Ord for <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.cmp" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#53">source</a><a href="#method.cmp" class="anchor"></a><h4 class="code-header">fn <a class="fnname">cmp</a>(&self, other: &<a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>) -> Ordering</h4></section></summary><div class='docblock'>This method returns an [<code>Ordering</code>] between <code>self</code> and <code>other</code>. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.max" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.21.0">1.21.0</span><a href="#method.max" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">max</a>(self, other: Self) -> Self</h4></section></summary><div class='docblock'>Compares and returns the maximum of two values. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.min" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.21.0">1.21.0</span><a href="#method.min" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">min</a>(self, other: Self) -> Self</h4></section></summary><div class='docblock'>Compares and returns the minimum of two values. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.clamp" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.50.0">1.50.0</span><a href="#method.clamp" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">clamp</a>(self, min: Self, max: Self) -> Self<span class="where fmt-newline">where<br> Self: PartialOrd<Self>,</span></h4></section></summary><div class='docblock'>Restrict a value to a certain interval. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-PartialEq%3CDuration%3E-for-Duration" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#53">source</a><a href="#impl-PartialEq%3CDuration%3E-for-Duration" class="anchor"></a><h3 class="code-header">impl PartialEq<<a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>> for <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.eq" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#53">source</a><a href="#method.eq" class="anchor"></a><h4 class="code-header">fn <a class="fnname">eq</a>(&self, other: &<a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>) -> bool</h4></section></summary><div class='docblock'>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used |
| by <code>==</code>. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ne" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.ne" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">ne</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests for <code>!=</code>. The default implementation is almost always |
| sufficient, and should not be overridden without very good reason. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-PartialOrd%3CDuration%3E-for-Duration" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#53">source</a><a href="#impl-PartialOrd%3CDuration%3E-for-Duration" class="anchor"></a><h3 class="code-header">impl PartialOrd<<a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>> for <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.partial_cmp" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#53">source</a><a href="#method.partial_cmp" class="anchor"></a><h4 class="code-header">fn <a class="fnname">partial_cmp</a>(&self, other: &<a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>) -> Option<Ordering></h4></section></summary><div class='docblock'>This method returns an ordering between <code>self</code> and <code>other</code> values if one exists. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.lt" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.lt" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">lt</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests less than (for <code>self</code> and <code>other</code>) and is used by the <code><</code> operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.le" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.le" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">le</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests less than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code><=</code> |
| operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.gt" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.gt" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">gt</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests greater than (for <code>self</code> and <code>other</code>) and is used by the <code>></code> operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ge" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.ge" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">ge</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests greater than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code>>=</code> |
| operator. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Sub%3CDuration%3E-for-Date%3CTz%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/date.rs.html#520-527">source</a><a href="#impl-Sub%3CDuration%3E-for-Date%3CTz%3E" class="anchor"></a><h3 class="code-header">impl<Tz: <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>> Sub<<a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>> for <a class="struct" href="struct.Date.html" title="struct chrono::Date">Date</a><Tz></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Output-6" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Output-6" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Output</a> = <a class="struct" href="struct.Date.html" title="struct chrono::Date">Date</a><Tz></h4></section></summary><div class='docblock'>The resulting type after applying the <code>-</code> operator.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.sub-1" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/date.rs.html#524-526">source</a><a href="#method.sub-1" class="anchor"></a><h4 class="code-header">fn <a class="fnname">sub</a>(self, rhs: <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">OldDuration</a>) -> <a class="struct" href="struct.Date.html" title="struct chrono::Date">Date</a><Tz></h4></section></summary><div class='docblock'>Performs the <code>-</code> operation. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Sub%3CDuration%3E-for-DateTime%3CTz%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#1013-1020">source</a><a href="#impl-Sub%3CDuration%3E-for-DateTime%3CTz%3E" class="anchor"></a><h3 class="code-header">impl<Tz: <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>> Sub<<a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>> for <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Output-8" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Output-8" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Output</a> = <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h4></section></summary><div class='docblock'>The resulting type after applying the <code>-</code> operator.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.sub-2" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#1017-1019">source</a><a href="#method.sub-2" class="anchor"></a><h4 class="code-header">fn <a class="fnname">sub</a>(self, rhs: <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">OldDuration</a>) -> <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h4></section></summary><div class='docblock'>Performs the <code>-</code> operation. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Sub%3CDuration%3E-for-Duration" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#345-357">source</a><a href="#impl-Sub%3CDuration%3E-for-Duration" class="anchor"></a><h3 class="code-header">impl Sub<<a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>> for <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Output-2" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Output-2" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Output</a> = <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h4></section></summary><div class='docblock'>The resulting type after applying the <code>-</code> operator.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.sub" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#348-356">source</a><a href="#method.sub" class="anchor"></a><h4 class="code-header">fn <a class="fnname">sub</a>(self, rhs: <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>) -> <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h4></section></summary><div class='docblock'>Performs the <code>-</code> operation. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Sub%3CDuration%3E-for-NaiveDate" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/naive/date.rs.html#1837-1844">source</a><a href="#impl-Sub%3CDuration%3E-for-NaiveDate" class="anchor"></a><h3 class="code-header">impl Sub<<a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>> for <a class="struct" href="naive/struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h3></section></summary><div class="docblock"><p>A subtraction of <code>Duration</code> from <code>NaiveDate</code> discards the fractional days, |
| rounding to the closest integral number of days towards <code>Duration::zero()</code>. |
| It is the same as the addition with a negated <code>Duration</code>.</p> |
| <p>Panics on underflow or overflow. Use <a href="naive/struct.NaiveDate.html#method.checked_sub_signed"><code>NaiveDate::checked_sub_signed</code></a> to detect that.</p> |
| <h4 id="example-1"><a href="#example-1">Example</a></h4> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{Duration, NaiveDate}; |
| |
| <span class="kw">let </span>from_ymd = |y, m, d| NaiveDate::from_ymd_opt(y, m, d).unwrap(); |
| |
| <span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) - Duration::zero(), from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>)); |
| <span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) - Duration::seconds(<span class="number">86399</span>), from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>)); |
| <span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) - Duration::seconds(-<span class="number">86399</span>), from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>)); |
| <span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) - Duration::days(<span class="number">1</span>), from_ymd(<span class="number">2013</span>, <span class="number">12</span>, <span class="number">31</span>)); |
| <span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) - Duration::days(-<span class="number">1</span>), from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">2</span>)); |
| <span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) - Duration::days(<span class="number">364</span>), from_ymd(<span class="number">2013</span>, <span class="number">1</span>, <span class="number">2</span>)); |
| <span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) - Duration::days(<span class="number">365</span><span class="kw-2">*</span><span class="number">4 </span>+ <span class="number">1</span>), from_ymd(<span class="number">2010</span>, <span class="number">1</span>, <span class="number">1</span>)); |
| <span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) - Duration::days(<span class="number">365</span><span class="kw-2">*</span><span class="number">400 </span>+ <span class="number">97</span>), from_ymd(<span class="number">1614</span>, <span class="number">1</span>, <span class="number">1</span>));</code></pre></div> |
| </div><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Output-10" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Output-10" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Output</a> = <a class="struct" href="naive/struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h4></section></summary><div class='docblock'>The resulting type after applying the <code>-</code> operator.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.sub-3" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/naive/date.rs.html#1841-1843">source</a><a href="#method.sub-3" class="anchor"></a><h4 class="code-header">fn <a class="fnname">sub</a>(self, rhs: <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">OldDuration</a>) -> <a class="struct" href="naive/struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h4></section></summary><div class='docblock'>Performs the <code>-</code> operation. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Sub%3CDuration%3E-for-NaiveDateTime" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/naive/datetime/mod.rs.html#1577-1584">source</a><a href="#impl-Sub%3CDuration%3E-for-NaiveDateTime" class="anchor"></a><h3 class="code-header">impl Sub<<a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>> for <a class="struct" href="naive/struct.NaiveDateTime.html" title="struct chrono::naive::NaiveDateTime">NaiveDateTime</a></h3></section></summary><div class="docblock"><p>A subtraction of <code>Duration</code> from <code>NaiveDateTime</code> yields another <code>NaiveDateTime</code>. |
| It is the same as the addition with a negated <code>Duration</code>.</p> |
| <p>As a part of Chrono’s <a href="naive/struct.NaiveTime.html#leap-second-handling">leap second handling</a> the subtraction assumes that <strong>there is no leap |
| second ever</strong>, except when the <code>NaiveDateTime</code> itself represents a leap second in which case |
| the assumption becomes that <strong>there is exactly a single leap second ever</strong>.</p> |
| <p>Panics on underflow or overflow. Use <a href="naive/struct.NaiveDateTime.html#method.checked_sub_signed" title="NaiveDateTime::checked_sub_signed"><code>NaiveDateTime::checked_sub_signed</code></a> |
| to detect that.</p> |
| <h4 id="example-3"><a href="#example-3">Example</a></h4> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{Duration, NaiveDate}; |
| |
| <span class="kw">let </span>from_ymd = |y, m, d| NaiveDate::from_ymd_opt(y, m, d).unwrap(); |
| |
| <span class="kw">let </span>d = from_ymd(<span class="number">2016</span>, <span class="number">7</span>, <span class="number">8</span>); |
| <span class="kw">let </span>hms = |h, m, s| d.and_hms_opt(h, m, s).unwrap(); |
| <span class="macro">assert_eq!</span>(hms(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>) - Duration::zero(), hms(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>)); |
| <span class="macro">assert_eq!</span>(hms(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>) - Duration::seconds(<span class="number">1</span>), hms(<span class="number">3</span>, <span class="number">5</span>, <span class="number">6</span>)); |
| <span class="macro">assert_eq!</span>(hms(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>) - Duration::seconds(-<span class="number">1</span>), hms(<span class="number">3</span>, <span class="number">5</span>, <span class="number">8</span>)); |
| <span class="macro">assert_eq!</span>(hms(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>) - Duration::seconds(<span class="number">3600 </span>+ <span class="number">60</span>), hms(<span class="number">2</span>, <span class="number">4</span>, <span class="number">7</span>)); |
| <span class="macro">assert_eq!</span>(hms(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>) - Duration::seconds(<span class="number">86_400</span>), |
| from_ymd(<span class="number">2016</span>, <span class="number">7</span>, <span class="number">7</span>).and_hms_opt(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>).unwrap()); |
| <span class="macro">assert_eq!</span>(hms(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>) - Duration::days(<span class="number">365</span>), |
| from_ymd(<span class="number">2015</span>, <span class="number">7</span>, <span class="number">9</span>).and_hms_opt(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>).unwrap()); |
| |
| <span class="kw">let </span>hmsm = |h, m, s, milli| d.and_hms_milli_opt(h, m, s, milli).unwrap(); |
| <span class="macro">assert_eq!</span>(hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">450</span>) - Duration::milliseconds(<span class="number">670</span>), hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">780</span>));</code></pre></div> |
| <p>Leap seconds are handled, |
| but the subtraction assumes that it is the only leap second happened.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>leap = hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">59</span>, <span class="number">1_300</span>); |
| <span class="macro">assert_eq!</span>(leap - Duration::zero(), hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">59</span>, <span class="number">1_300</span>)); |
| <span class="macro">assert_eq!</span>(leap - Duration::milliseconds(<span class="number">200</span>), hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">59</span>, <span class="number">1_100</span>)); |
| <span class="macro">assert_eq!</span>(leap - Duration::milliseconds(<span class="number">500</span>), hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">59</span>, <span class="number">800</span>)); |
| <span class="macro">assert_eq!</span>(leap - Duration::seconds(<span class="number">60</span>), hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">0</span>, <span class="number">300</span>)); |
| <span class="macro">assert_eq!</span>(leap - Duration::days(<span class="number">1</span>), |
| from_ymd(<span class="number">2016</span>, <span class="number">7</span>, <span class="number">7</span>).and_hms_milli_opt(<span class="number">3</span>, <span class="number">6</span>, <span class="number">0</span>, <span class="number">300</span>).unwrap());</code></pre></div> |
| </div><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Output-12" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Output-12" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Output</a> = <a class="struct" href="naive/struct.NaiveDateTime.html" title="struct chrono::naive::NaiveDateTime">NaiveDateTime</a></h4></section></summary><div class='docblock'>The resulting type after applying the <code>-</code> operator.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.sub-4" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/naive/datetime/mod.rs.html#1581-1583">source</a><a href="#method.sub-4" class="anchor"></a><h4 class="code-header">fn <a class="fnname">sub</a>(self, rhs: <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">OldDuration</a>) -> <a class="struct" href="naive/struct.NaiveDateTime.html" title="struct chrono::naive::NaiveDateTime">NaiveDateTime</a></h4></section></summary><div class='docblock'>Performs the <code>-</code> operation. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Sub%3CDuration%3E-for-NaiveTime" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/naive/time/mod.rs.html#1123-1130">source</a><a href="#impl-Sub%3CDuration%3E-for-NaiveTime" class="anchor"></a><h3 class="code-header">impl Sub<<a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>> for <a class="struct" href="naive/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a></h3></section></summary><div class="docblock"><p>A subtraction of <code>Duration</code> from <code>NaiveTime</code> wraps around and never overflows or underflows. |
| In particular the addition ignores integral number of days. |
| It is the same as the addition with a negated <code>Duration</code>.</p> |
| <p>As a part of Chrono’s <a href="naive/struct.NaiveTime.html#leap-second-handling">leap second handling</a>, the subtraction assumes that <strong>there is no leap |
| second ever</strong>, except when the <code>NaiveTime</code> itself represents a leap second in which case the |
| assumption becomes that <strong>there is exactly a single leap second ever</strong>.</p> |
| <h4 id="example-5"><a href="#example-5">Example</a></h4> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{Duration, NaiveTime}; |
| |
| <span class="kw">let </span>from_hmsm = |h, m, s, milli| { NaiveTime::from_hms_milli_opt(h, m, s, milli).unwrap() }; |
| |
| <span class="macro">assert_eq!</span>(from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) - Duration::zero(), from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>)); |
| <span class="macro">assert_eq!</span>(from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) - Duration::seconds(<span class="number">1</span>), from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">0</span>)); |
| <span class="macro">assert_eq!</span>(from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) - Duration::seconds(<span class="number">60 </span>+ <span class="number">5</span>), from_hmsm(<span class="number">3</span>, <span class="number">4</span>, <span class="number">2</span>, <span class="number">0</span>)); |
| <span class="macro">assert_eq!</span>(from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) - Duration::seconds(<span class="number">2</span><span class="kw-2">*</span><span class="number">60</span><span class="kw-2">*</span><span class="number">60 </span>+ <span class="number">6</span><span class="kw-2">*</span><span class="number">60</span>), from_hmsm(<span class="number">0</span>, <span class="number">59</span>, <span class="number">7</span>, <span class="number">0</span>)); |
| <span class="macro">assert_eq!</span>(from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) - Duration::milliseconds(<span class="number">80</span>), from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">920</span>)); |
| <span class="macro">assert_eq!</span>(from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">950</span>) - Duration::milliseconds(<span class="number">280</span>), from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">670</span>));</code></pre></div> |
| <p>The subtraction wraps around.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) - Duration::seconds(<span class="number">8</span><span class="kw-2">*</span><span class="number">60</span><span class="kw-2">*</span><span class="number">60</span>), from_hmsm(<span class="number">19</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>)); |
| <span class="macro">assert_eq!</span>(from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) - Duration::days(<span class="number">800</span>), from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>));</code></pre></div> |
| <p>Leap seconds are handled, but the subtraction assumes that it is the only leap second happened.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>leap = from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">59</span>, <span class="number">1_300</span>); |
| <span class="macro">assert_eq!</span>(leap - Duration::zero(), from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">59</span>, <span class="number">1_300</span>)); |
| <span class="macro">assert_eq!</span>(leap - Duration::milliseconds(<span class="number">200</span>), from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">59</span>, <span class="number">1_100</span>)); |
| <span class="macro">assert_eq!</span>(leap - Duration::milliseconds(<span class="number">500</span>), from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">59</span>, <span class="number">800</span>)); |
| <span class="macro">assert_eq!</span>(leap - Duration::seconds(<span class="number">60</span>), from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">0</span>, <span class="number">300</span>)); |
| <span class="macro">assert_eq!</span>(leap - Duration::days(<span class="number">1</span>), from_hmsm(<span class="number">3</span>, <span class="number">6</span>, <span class="number">0</span>, <span class="number">300</span>));</code></pre></div> |
| </div><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Output-14" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Output-14" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Output</a> = <a class="struct" href="naive/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a></h4></section></summary><div class='docblock'>The resulting type after applying the <code>-</code> operator.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.sub-5" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/naive/time/mod.rs.html#1127-1129">source</a><a href="#method.sub-5" class="anchor"></a><h4 class="code-header">fn <a class="fnname">sub</a>(self, rhs: <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">OldDuration</a>) -> <a class="struct" href="naive/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a></h4></section></summary><div class='docblock'>Performs the <code>-</code> operation. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-SubAssign%3CDuration%3E-for-Date%3CTz%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/date.rs.html#529-534">source</a><a href="#impl-SubAssign%3CDuration%3E-for-Date%3CTz%3E" class="anchor"></a><h3 class="code-header">impl<Tz: <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>> SubAssign<<a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>> for <a class="struct" href="struct.Date.html" title="struct chrono::Date">Date</a><Tz></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.sub_assign" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/date.rs.html#531-533">source</a><a href="#method.sub_assign" class="anchor"></a><h4 class="code-header">fn <a class="fnname">sub_assign</a>(&mut self, rhs: <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">OldDuration</a>)</h4></section></summary><div class='docblock'>Performs the <code>-=</code> operation. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-SubAssign%3CDuration%3E-for-DateTime%3CTz%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#1022-1030">source</a><a href="#impl-SubAssign%3CDuration%3E-for-DateTime%3CTz%3E" class="anchor"></a><h3 class="code-header">impl<Tz: <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>> SubAssign<<a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>> for <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.sub_assign-1" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#1024-1029">source</a><a href="#method.sub_assign-1" class="anchor"></a><h4 class="code-header">fn <a class="fnname">sub_assign</a>(&mut self, rhs: <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">OldDuration</a>)</h4></section></summary><div class='docblock'>Performs the <code>-=</code> operation. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-SubAssign%3CDuration%3E-for-NaiveDate" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/naive/date.rs.html#1846-1851">source</a><a href="#impl-SubAssign%3CDuration%3E-for-NaiveDate" class="anchor"></a><h3 class="code-header">impl SubAssign<<a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>> for <a class="struct" href="naive/struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.sub_assign-2" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/naive/date.rs.html#1848-1850">source</a><a href="#method.sub_assign-2" class="anchor"></a><h4 class="code-header">fn <a class="fnname">sub_assign</a>(&mut self, rhs: <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">OldDuration</a>)</h4></section></summary><div class='docblock'>Performs the <code>-=</code> operation. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-SubAssign%3CDuration%3E-for-NaiveDateTime" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/naive/datetime/mod.rs.html#1586-1591">source</a><a href="#impl-SubAssign%3CDuration%3E-for-NaiveDateTime" class="anchor"></a><h3 class="code-header">impl SubAssign<<a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>> for <a class="struct" href="naive/struct.NaiveDateTime.html" title="struct chrono::naive::NaiveDateTime">NaiveDateTime</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.sub_assign-3" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/naive/datetime/mod.rs.html#1588-1590">source</a><a href="#method.sub_assign-3" class="anchor"></a><h4 class="code-header">fn <a class="fnname">sub_assign</a>(&mut self, rhs: <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">OldDuration</a>)</h4></section></summary><div class='docblock'>Performs the <code>-=</code> operation. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-SubAssign%3CDuration%3E-for-NaiveTime" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/naive/time/mod.rs.html#1132-1137">source</a><a href="#impl-SubAssign%3CDuration%3E-for-NaiveTime" class="anchor"></a><h3 class="code-header">impl SubAssign<<a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>> for <a class="struct" href="naive/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.sub_assign-4" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/naive/time/mod.rs.html#1134-1136">source</a><a href="#method.sub_assign-4" class="anchor"></a><h4 class="code-header">fn <a class="fnname">sub_assign</a>(&mut self, rhs: <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">OldDuration</a>)</h4></section></summary><div class='docblock'>Performs the <code>-=</code> operation. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Sum%3C%26%27a%20Duration%3E-for-Duration" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#393-397">source</a><a href="#impl-Sum%3C%26%27a%20Duration%3E-for-Duration" class="anchor"></a><h3 class="code-header">impl<'a> Sum<&'a <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>> for <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.sum" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#394-396">source</a><a href="#method.sum" class="anchor"></a><h4 class="code-header">fn <a class="fnname">sum</a><I: Iterator<Item = &'a <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>>>(iter: I) -> <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h4></section></summary><div class='docblock'>Method which takes an iterator and generates <code>Self</code> from the elements by |
| “summing up” the items. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Sum%3CDuration%3E-for-Duration" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#401-405">source</a><a href="#impl-Sum%3CDuration%3E-for-Duration" class="anchor"></a><h3 class="code-header">impl Sum<<a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>> for <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.sum-1" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#402-404">source</a><a href="#method.sum-1" class="anchor"></a><h4 class="code-header">fn <a class="fnname">sum</a><I: Iterator<Item = <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>>>(iter: I) -> <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h4></section></summary><div class='docblock'>Method which takes an iterator and generates <code>Self</code> from the elements by |
| “summing up” the items. <a>Read more</a></div></details></div></details><section id="impl-Copy-for-Duration" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#53">source</a><a href="#impl-Copy-for-Duration" class="anchor"></a><h3 class="code-header">impl Copy for <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h3></section><section id="impl-Eq-for-Duration" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#53">source</a><a href="#impl-Eq-for-Duration" class="anchor"></a><h3 class="code-header">impl Eq for <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h3></section><section id="impl-StructuralEq-for-Duration" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#53">source</a><a href="#impl-StructuralEq-for-Duration" class="anchor"></a><h3 class="code-header">impl StructuralEq for <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h3></section><section id="impl-StructuralPartialEq-for-Duration" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/oldtime.rs.html#53">source</a><a href="#impl-StructuralPartialEq-for-Duration" class="anchor"></a><h3 class="code-header">impl StructuralPartialEq for <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h3></section></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><section id="impl-RefUnwindSafe-for-Duration" class="impl has-srclink"><a href="#impl-RefUnwindSafe-for-Duration" class="anchor"></a><h3 class="code-header">impl RefUnwindSafe for <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h3></section><section id="impl-Send-for-Duration" class="impl has-srclink"><a href="#impl-Send-for-Duration" class="anchor"></a><h3 class="code-header">impl Send for <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h3></section><section id="impl-Sync-for-Duration" class="impl has-srclink"><a href="#impl-Sync-for-Duration" class="anchor"></a><h3 class="code-header">impl Sync for <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h3></section><section id="impl-Unpin-for-Duration" class="impl has-srclink"><a href="#impl-Unpin-for-Duration" class="anchor"></a><h3 class="code-header">impl Unpin for <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h3></section><section id="impl-UnwindSafe-for-Duration" class="impl has-srclink"><a href="#impl-UnwindSafe-for-Duration" class="anchor"></a><h3 class="code-header">impl UnwindSafe for <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h3></section></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Any-for-Duration" class="impl has-srclink"><a href="#impl-Any-for-Duration" class="anchor"></a><h3 class="code-header">impl<T> Any for T<span class="where fmt-newline">where<br> T: 'static + ?Sized,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl has-srclink"><a href="#method.type_id" class="anchor"></a><h4 class="code-header">fn <a class="fnname">type_id</a>(&self) -> TypeId</h4></section></summary><div class='docblock'>Gets the <code>TypeId</code> of <code>self</code>. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-Duration" class="impl has-srclink"><a href="#impl-Borrow%3CT%3E-for-Duration" class="anchor"></a><h3 class="code-header">impl<T> Borrow<T> for T<span class="where fmt-newline">where<br> T: ?Sized,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl has-srclink"><span class="since rightside" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/91522" title="Tracking issue for const_borrow">unstable</a></span><a href="#method.borrow" class="anchor"></a><h4 class="code-header">fn <a class="fnname">borrow</a>(&self) -> &T</h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-Duration" class="impl has-srclink"><a href="#impl-BorrowMut%3CT%3E-for-Duration" class="anchor"></a><h3 class="code-header">impl<T> BorrowMut<T> for T<span class="where fmt-newline">where<br> T: ?Sized,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl has-srclink"><span class="since rightside" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/91522" title="Tracking issue for const_borrow">unstable</a></span><a href="#method.borrow_mut" class="anchor"></a><h4 class="code-header">fn <a class="fnname">borrow_mut</a>(&mut self) -> &mut T</h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-Duration" class="impl has-srclink"><a href="#impl-From%3CT%3E-for-Duration" class="anchor"></a><h3 class="code-header">impl<T> From<T> for T</h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from" class="method trait-impl has-srclink"><span class="since rightside" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span><a href="#method.from" class="anchor"></a><h4 class="code-header">fn <a class="fnname">from</a>(t: T) -> T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p> |
| </div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-Duration" class="impl has-srclink"><a href="#impl-Into%3CU%3E-for-Duration" class="anchor"></a><h3 class="code-header">impl<T, U> Into<U> for T<span class="where fmt-newline">where<br> U: From<T>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.into" class="method trait-impl has-srclink"><span class="since rightside" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span><a href="#method.into" class="anchor"></a><h4 class="code-header">fn <a class="fnname">into</a>(self) -> U</h4></section></summary><div class="docblock"><p>Calls <code>U::from(self)</code>.</p> |
| <p>That is, this conversion is whatever the implementation of |
| <code>[From]<T> for U</code> chooses to do.</p> |
| </div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-ToOwned-for-Duration" class="impl has-srclink"><a href="#impl-ToOwned-for-Duration" class="anchor"></a><h3 class="code-header">impl<T> ToOwned for T<span class="where fmt-newline">where<br> T: Clone,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Owned" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Owned" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Owned</a> = T</h4></section></summary><div class='docblock'>The resulting type after obtaining ownership.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.to_owned" class="method trait-impl has-srclink"><a href="#method.to_owned" class="anchor"></a><h4 class="code-header">fn <a class="fnname">to_owned</a>(&self) -> T</h4></section></summary><div class='docblock'>Creates owned data from borrowed data, usually by cloning. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.clone_into" class="method trait-impl has-srclink"><a href="#method.clone_into" class="anchor"></a><h4 class="code-header">fn <a class="fnname">clone_into</a>(&self, target: &mut T)</h4></section></summary><div class='docblock'>Uses borrowed data to replace owned data, usually by cloning. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-ToString-for-Duration" class="impl has-srclink"><a href="#impl-ToString-for-Duration" class="anchor"></a><h3 class="code-header">impl<T> ToString for T<span class="where fmt-newline">where<br> T: Display + ?Sized,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.to_string" class="method trait-impl has-srclink"><a href="#method.to_string" class="anchor"></a><h4 class="code-header">default fn <a class="fnname">to_string</a>(&self) -> String</h4></section></summary><div class='docblock'>Converts the given value to a <code>String</code>. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-Duration" class="impl has-srclink"><a href="#impl-TryFrom%3CU%3E-for-Duration" class="anchor"></a><h3 class="code-header">impl<T, U> TryFrom<U> for T<span class="where fmt-newline">where<br> U: Into<T>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error-1" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Error</a> = Infallible</h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl has-srclink"><span class="since rightside" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span><a href="#method.try_from" class="anchor"></a><h4 class="code-header">fn <a class="fnname">try_from</a>(value: U) -> Result<T, <T as TryFrom<U>>::Error></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-Duration" class="impl has-srclink"><a href="#impl-TryInto%3CU%3E-for-Duration" class="anchor"></a><h3 class="code-header">impl<T, U> TryInto<U> for T<span class="where fmt-newline">where<br> U: TryFrom<T>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Error</a> = <U as TryFrom<T>>::Error</h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl has-srclink"><span class="since rightside" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span><a href="#method.try_into" class="anchor"></a><h4 class="code-header">fn <a class="fnname">try_into</a>(self) -> Result<U, <U as TryFrom<T>>::Error></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details></div></section></div></main><div id="rustdoc-vars" data-root-path="../" data-current-crate="chrono" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.66.0-nightly (5c8bff74b 2022-10-21)" ></div></body></html> |