| <!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="Combined date and time."><meta name="keywords" content="rust, rustlang, rust-lang, PrimitiveDateTime"><title>PrimitiveDateTime in time - 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="icon" href="https://avatars0.githubusercontent.com/u/55999857"></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="../time/index.html"><div class="logo-container"><img src="https://avatars0.githubusercontent.com/u/55999857" alt="logo"></div></a><h2></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../time/index.html"><div class="logo-container"> |
| <img src="https://avatars0.githubusercontent.com/u/55999857" alt="logo"></div></a><h2 class="location"><a href="#">PrimitiveDateTime</a></h2><div class="sidebar-elems"><section><h3><a href="#implementations">Associated Constants</a></h3><ul class="block"><li><a href="#associatedconstant.MAX">MAX</a></li><li><a href="#associatedconstant.MIN">MIN</a></li></ul><h3><a href="#implementations">Methods</a></h3><ul class="block"><li><a href="#method.as_hms">as_hms</a></li><li><a href="#method.as_hms_micro">as_hms_micro</a></li><li><a href="#method.as_hms_milli">as_hms_milli</a></li><li><a href="#method.as_hms_nano">as_hms_nano</a></li><li><a href="#method.assume_offset">assume_offset</a></li><li><a href="#method.assume_utc">assume_utc</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.date">date</a></li><li><a href="#method.day">day</a></li><li><a href="#method.format">format</a></li><li><a href="#method.format_into">format_into</a></li><li><a href="#method.hour">hour</a></li><li><a href="#method.iso_week">iso_week</a></li><li><a href="#method.microsecond">microsecond</a></li><li><a href="#method.millisecond">millisecond</a></li><li><a href="#method.minute">minute</a></li><li><a href="#method.monday_based_week">monday_based_week</a></li><li><a href="#method.month">month</a></li><li><a href="#method.nanosecond">nanosecond</a></li><li><a href="#method.new">new</a></li><li><a href="#method.ordinal">ordinal</a></li><li><a href="#method.parse">parse</a></li><li><a href="#method.replace_date">replace_date</a></li><li><a href="#method.replace_day">replace_day</a></li><li><a href="#method.replace_hour">replace_hour</a></li><li><a href="#method.replace_microsecond">replace_microsecond</a></li><li><a href="#method.replace_millisecond">replace_millisecond</a></li><li><a href="#method.replace_minute">replace_minute</a></li><li><a href="#method.replace_month">replace_month</a></li><li><a href="#method.replace_nanosecond">replace_nanosecond</a></li><li><a href="#method.replace_second">replace_second</a></li><li><a href="#method.replace_time">replace_time</a></li><li><a href="#method.replace_year">replace_year</a></li><li><a href="#method.saturating_add">saturating_add</a></li><li><a href="#method.saturating_sub">saturating_sub</a></li><li><a href="#method.second">second</a></li><li><a href="#method.sunday_based_week">sunday_based_week</a></li><li><a href="#method.time">time</a></li><li><a href="#method.to_calendar_date">to_calendar_date</a></li><li><a href="#method.to_iso_week_date">to_iso_week_date</a></li><li><a href="#method.to_julian_day">to_julian_day</a></li><li><a href="#method.to_ordinal_date">to_ordinal_date</a></li><li><a href="#method.weekday">weekday</a></li><li><a href="#method.year">year</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block"><li><a href="#impl-Add%3CDuration%3E-for-PrimitiveDateTime">Add<Duration></a></li><li><a href="#impl-Add%3CDuration%3E-for-PrimitiveDateTime-1">Add<Duration></a></li><li><a href="#impl-AddAssign%3CDuration%3E-for-PrimitiveDateTime">AddAssign<Duration></a></li><li><a href="#impl-AddAssign%3CDuration%3E-for-PrimitiveDateTime-1">AddAssign<Duration></a></li><li><a href="#impl-Clone-for-PrimitiveDateTime">Clone</a></li><li><a href="#impl-Copy-for-PrimitiveDateTime">Copy</a></li><li><a href="#impl-Debug-for-PrimitiveDateTime">Debug</a></li><li><a href="#impl-Deserialize%3C%27a%3E-for-PrimitiveDateTime">Deserialize<'a></a></li><li><a href="#impl-Display-for-PrimitiveDateTime">Display</a></li><li><a href="#impl-Eq-for-PrimitiveDateTime">Eq</a></li><li><a href="#impl-Hash-for-PrimitiveDateTime">Hash</a></li><li><a href="#impl-Ord-for-PrimitiveDateTime">Ord</a></li><li><a href="#impl-PartialEq%3CPrimitiveDateTime%3E-for-PrimitiveDateTime">PartialEq<PrimitiveDateTime></a></li><li><a href="#impl-PartialOrd%3CPrimitiveDateTime%3E-for-PrimitiveDateTime">PartialOrd<PrimitiveDateTime></a></li><li><a href="#impl-Serialize-for-PrimitiveDateTime">Serialize</a></li><li><a href="#impl-StructuralEq-for-PrimitiveDateTime">StructuralEq</a></li><li><a href="#impl-StructuralPartialEq-for-PrimitiveDateTime">StructuralPartialEq</a></li><li><a href="#impl-Sub%3CDuration%3E-for-PrimitiveDateTime">Sub<Duration></a></li><li><a href="#impl-Sub%3CDuration%3E-for-PrimitiveDateTime-1">Sub<Duration></a></li><li><a href="#impl-Sub%3CPrimitiveDateTime%3E-for-PrimitiveDateTime">Sub<PrimitiveDateTime></a></li><li><a href="#impl-SubAssign%3CDuration%3E-for-PrimitiveDateTime">SubAssign<Duration></a></li><li><a href="#impl-SubAssign%3CDuration%3E-for-PrimitiveDateTime-1">SubAssign<Duration></a></li><li><a href="#impl-TryFrom%3CParsed%3E-for-PrimitiveDateTime">TryFrom<Parsed></a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block"><li><a href="#impl-RefUnwindSafe-for-PrimitiveDateTime">RefUnwindSafe</a></li><li><a href="#impl-Send-for-PrimitiveDateTime">Send</a></li><li><a href="#impl-Sync-for-PrimitiveDateTime">Sync</a></li><li><a href="#impl-Unpin-for-PrimitiveDateTime">Unpin</a></li><li><a href="#impl-UnwindSafe-for-PrimitiveDateTime">UnwindSafe</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block"><li><a href="#impl-Any-for-PrimitiveDateTime">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-PrimitiveDateTime">Borrow<T></a></li><li><a href="#impl-BorrowMut%3CT%3E-for-PrimitiveDateTime">BorrowMut<T></a></li><li><a href="#impl-DeserializeOwned-for-PrimitiveDateTime">DeserializeOwned</a></li><li><a href="#impl-From%3CT%3E-for-PrimitiveDateTime">From<T></a></li><li><a href="#impl-Into%3CU%3E-for-PrimitiveDateTime">Into<U></a></li><li><a href="#impl-ToOwned-for-PrimitiveDateTime">ToOwned</a></li><li><a href="#impl-ToString-for-PrimitiveDateTime">ToString</a></li><li><a href="#impl-TryFrom%3CU%3E-for-PrimitiveDateTime">TryFrom<U></a></li><li><a href="#impl-TryInto%3CU%3E-for-PrimitiveDateTime">TryInto<U></a></li></ul></section><h2><a href="index.html">In time</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">time</a>::<wbr><a class="struct" href="#">PrimitiveDateTime</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/time/primitive_date_time.rs.html#21">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 PrimitiveDateTime(_);</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Combined date and time.</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-PrimitiveDateTime" class="impl has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#23-575">source</a><a href="#impl-PrimitiveDateTime" class="anchor"></a><h3 class="code-header">impl <a class="struct" href="struct.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedconstant.MIN" class="associatedconstant has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#51">source</a><h4 class="code-header">pub const <a href="#associatedconstant.MIN" class="constant">MIN</a>: Self = _</h4></section></summary><div class="docblock"><p>The smallest value that can be represented by <code>PrimitiveDateTime</code>.</p> |
| <p>Depending on <code>large-dates</code> feature flag, value of this constant may vary.</p> |
| <ol> |
| <li>With <code>large-dates</code> disabled it is equal to <code>-9999-01-01 00:00:00.0</code></li> |
| <li>With <code>large-dates</code> enabled it is equal to <code>-999999-01-01 00:00:00.0</code></li> |
| </ol> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="comment">// Assuming `large-dates` feature is disabled. |
| </span><span class="macro">assert_eq!</span>(PrimitiveDateTime::MIN, <span class="macro">datetime!</span>(-<span class="number">9999</span>-<span class="number">01</span>-<span class="number">01 0</span>:<span class="number">00</span>));</code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time%3A%3APrimitiveDateTime%3B%0Ause%20time_macros%3A%3Adatetime%3B%0A%2F%2F%20Assuming%20%60large-dates%60%20feature%20is%20disabled.%0Aassert_eq!(PrimitiveDateTime%3A%3AMIN%2C%20datetime!(-9999-01-01%200%3A00))%3B%0A%7D&edition=2021">Run</a></div> |
| </div></details><details class="rustdoc-toggle" open><summary><section id="associatedconstant.MAX" class="associatedconstant has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#80">source</a><h4 class="code-header">pub const <a href="#associatedconstant.MAX" class="constant">MAX</a>: Self = _</h4></section></summary><div class="docblock"><p>The largest value that can be represented by <code>PrimitiveDateTime</code>.</p> |
| <p>Depending on <code>large-dates</code> feature flag, value of this constant may vary.</p> |
| <ol> |
| <li>With <code>large-dates</code> disabled it is equal to <code>9999-12-31 23:59:59.999_999_999</code></li> |
| <li>With <code>large-dates</code> enabled it is equal to <code>999999-12-31 23:59:59.999_999_999</code></li> |
| </ol> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="comment">// Assuming `large-dates` feature is disabled. |
| </span><span class="macro">assert_eq!</span>(PrimitiveDateTime::MAX, <span class="macro">datetime!</span>(+<span class="number">9999</span>-<span class="number">12</span>-<span class="number">31 23</span>:<span class="number">59</span>:<span class="number">59.999_999_999</span>));</code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time%3A%3APrimitiveDateTime%3B%0Ause%20time_macros%3A%3Adatetime%3B%0A%2F%2F%20Assuming%20%60large-dates%60%20feature%20is%20disabled.%0Aassert_eq!(PrimitiveDateTime%3A%3AMAX%2C%20datetime!(%2B9999-12-31%2023%3A59%3A59.999_999_999))%3B%0A%7D&edition=2021">Run</a></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.new" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#92-94">source</a><h4 class="code-header">pub const fn <a href="#method.new" class="fnname">new</a>(date: <a class="struct" href="struct.Date.html" title="struct time::Date">Date</a>, time: <a class="struct" href="struct.Time.html" title="struct time::Time">Time</a>) -> Self</h4></section></summary><div class="docblock"><p>Create a new <code>PrimitiveDateTime</code> from the provided <a href="struct.Date.html" title="Date"><code>Date</code></a> and <a href="struct.Time.html" title="Time"><code>Time</code></a>.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>( |
| PrimitiveDateTime::new(<span class="macro">date!</span>(<span class="number">2019</span>-<span class="number">01</span>-<span class="number">01</span>), <span class="macro">time!</span>(<span class="number">0</span>:<span class="number">00</span>)), |
| <span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">01</span>-<span class="number">01 0</span>:<span class="number">00</span>), |
| );</code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time%3A%3APrimitiveDateTime%3B%0Ause%20time_macros%3A%3A%7Bdate%2C%20datetime%2C%20time%7D%3B%0Aassert_eq!(%0A%20%20%20%20PrimitiveDateTime%3A%3Anew(date!(2019-01-01)%2C%20time!(0%3A00))%2C%0A%20%20%20%20datetime!(2019-01-01%200%3A00)%2C%0A)%3B%0A%7D&edition=2021">Run</a></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.date" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#103-105">source</a><h4 class="code-header">pub const fn <a href="#method.date" class="fnname">date</a>(self) -> <a class="struct" href="struct.Date.html" title="struct time::Date">Date</a></h4></section></summary><div class="docblock"><p>Get the <a href="struct.Date.html" title="Date"><code>Date</code></a> component of the <code>PrimitiveDateTime</code>.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">01</span>-<span class="number">01 0</span>:<span class="number">00</span>).date(), <span class="macro">date!</span>(<span class="number">2019</span>-<span class="number">01</span>-<span class="number">01</span>));</code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time_macros%3A%3A%7Bdate%2C%20datetime%7D%3B%0Aassert_eq!(datetime!(2019-01-01%200%3A00).date()%2C%20date!(2019-01-01))%3B%0A%7D&edition=2021">Run</a></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.time" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#112-114">source</a><h4 class="code-header">pub const fn <a href="#method.time" class="fnname">time</a>(self) -> <a class="struct" href="struct.Time.html" title="struct time::Time">Time</a></h4></section></summary><div class="docblock"><p>Get the <a href="struct.Time.html" title="Time"><code>Time</code></a> component of the <code>PrimitiveDateTime</code>.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">01</span>-<span class="number">01 0</span>:<span class="number">00</span>).time(), <span class="macro">time!</span>(<span class="number">0</span>:<span class="number">00</span>));</code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time_macros%3A%3A%7Bdatetime%2C%20time%7D%3B%0Aassert_eq!(datetime!(2019-01-01%200%3A00).time()%2C%20time!(0%3A00))%3B%0A%7D&edition=2021">Run</a></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.year" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#126-128">source</a><h4 class="code-header">pub const fn <a href="#method.year" class="fnname">year</a>(self) -> i32</h4></section></summary><div class="docblock"><p>Get the year of the date.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">01</span>-<span class="number">01 0</span>:<span class="number">00</span>).year(), <span class="number">2019</span>); |
| <span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">12</span>-<span class="number">31 0</span>:<span class="number">00</span>).year(), <span class="number">2019</span>); |
| <span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2020</span>-<span class="number">01</span>-<span class="number">01 0</span>:<span class="number">00</span>).year(), <span class="number">2020</span>);</code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time_macros%3A%3Adatetime%3B%0Aassert_eq!(datetime!(2019-01-01%200%3A00).year()%2C%202019)%3B%0Aassert_eq!(datetime!(2019-12-31%200%3A00).year()%2C%202019)%3B%0Aassert_eq!(datetime!(2020-01-01%200%3A00).year()%2C%202020)%3B%0A%7D&edition=2021">Run</a></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.month" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#138-140">source</a><h4 class="code-header">pub const fn <a href="#method.month" class="fnname">month</a>(self) -> <a class="enum" href="enum.Month.html" title="enum time::Month">Month</a></h4></section></summary><div class="docblock"><p>Get the month of the date.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">01</span>-<span class="number">01 0</span>:<span class="number">00</span>).month(), Month::January); |
| <span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">12</span>-<span class="number">31 0</span>:<span class="number">00</span>).month(), Month::December);</code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time%3A%3AMonth%3B%0Ause%20time_macros%3A%3Adatetime%3B%0Aassert_eq!(datetime!(2019-01-01%200%3A00).month()%2C%20Month%3A%3AJanuary)%3B%0Aassert_eq!(datetime!(2019-12-31%200%3A00).month()%2C%20Month%3A%3ADecember)%3B%0A%7D&edition=2021">Run</a></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.day" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#151-153">source</a><h4 class="code-header">pub const fn <a href="#method.day" class="fnname">day</a>(self) -> u8</h4></section></summary><div class="docblock"><p>Get the day of the date.</p> |
| <p>The returned value will always be in the range <code>1..=31</code>.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">01</span>-<span class="number">01 0</span>:<span class="number">00</span>).day(), <span class="number">1</span>); |
| <span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">12</span>-<span class="number">31 0</span>:<span class="number">00</span>).day(), <span class="number">31</span>);</code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time_macros%3A%3Adatetime%3B%0Aassert_eq!(datetime!(2019-01-01%200%3A00).day()%2C%201)%3B%0Aassert_eq!(datetime!(2019-12-31%200%3A00).day()%2C%2031)%3B%0A%7D&edition=2021">Run</a></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ordinal" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#164-166">source</a><h4 class="code-header">pub const fn <a href="#method.ordinal" class="fnname">ordinal</a>(self) -> u16</h4></section></summary><div class="docblock"><p>Get the day of the year.</p> |
| <p>The returned value will always be in the range <code>1..=366</code> (<code>1..=365</code> for common years).</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">01</span>-<span class="number">01 0</span>:<span class="number">00</span>).ordinal(), <span class="number">1</span>); |
| <span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">12</span>-<span class="number">31 0</span>:<span class="number">00</span>).ordinal(), <span class="number">365</span>);</code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time_macros%3A%3Adatetime%3B%0Aassert_eq!(datetime!(2019-01-01%200%3A00).ordinal()%2C%201)%3B%0Aassert_eq!(datetime!(2019-12-31%200%3A00).ordinal()%2C%20365)%3B%0A%7D&edition=2021">Run</a></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.iso_week" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#180-182">source</a><h4 class="code-header">pub const fn <a href="#method.iso_week" class="fnname">iso_week</a>(self) -> u8</h4></section></summary><div class="docblock"><p>Get the ISO week number.</p> |
| <p>The returned value will always be in the range <code>1..=53</code>.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">01</span>-<span class="number">01 0</span>:<span class="number">00</span>).iso_week(), <span class="number">1</span>); |
| <span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">10</span>-<span class="number">04 0</span>:<span class="number">00</span>).iso_week(), <span class="number">40</span>); |
| <span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2020</span>-<span class="number">01</span>-<span class="number">01 0</span>:<span class="number">00</span>).iso_week(), <span class="number">1</span>); |
| <span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2020</span>-<span class="number">12</span>-<span class="number">31 0</span>:<span class="number">00</span>).iso_week(), <span class="number">53</span>); |
| <span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2021</span>-<span class="number">01</span>-<span class="number">01 0</span>:<span class="number">00</span>).iso_week(), <span class="number">53</span>);</code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time_macros%3A%3Adatetime%3B%0Aassert_eq!(datetime!(2019-01-01%200%3A00).iso_week()%2C%201)%3B%0Aassert_eq!(datetime!(2019-10-04%200%3A00).iso_week()%2C%2040)%3B%0Aassert_eq!(datetime!(2020-01-01%200%3A00).iso_week()%2C%201)%3B%0Aassert_eq!(datetime!(2020-12-31%200%3A00).iso_week()%2C%2053)%3B%0Aassert_eq!(datetime!(2021-01-01%200%3A00).iso_week()%2C%2053)%3B%0A%7D&edition=2021">Run</a></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.sunday_based_week" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#195-197">source</a><h4 class="code-header">pub const fn <a href="#method.sunday_based_week" class="fnname">sunday_based_week</a>(self) -> u8</h4></section></summary><div class="docblock"><p>Get the week number where week 1 begins on the first Sunday.</p> |
| <p>The returned value will always be in the range <code>0..=53</code>.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">01</span>-<span class="number">01 0</span>:<span class="number">00</span>).sunday_based_week(), <span class="number">0</span>); |
| <span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2020</span>-<span class="number">01</span>-<span class="number">01 0</span>:<span class="number">00</span>).sunday_based_week(), <span class="number">0</span>); |
| <span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2020</span>-<span class="number">12</span>-<span class="number">31 0</span>:<span class="number">00</span>).sunday_based_week(), <span class="number">52</span>); |
| <span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2021</span>-<span class="number">01</span>-<span class="number">01 0</span>:<span class="number">00</span>).sunday_based_week(), <span class="number">0</span>);</code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time_macros%3A%3Adatetime%3B%0Aassert_eq!(datetime!(2019-01-01%200%3A00).sunday_based_week()%2C%200)%3B%0Aassert_eq!(datetime!(2020-01-01%200%3A00).sunday_based_week()%2C%200)%3B%0Aassert_eq!(datetime!(2020-12-31%200%3A00).sunday_based_week()%2C%2052)%3B%0Aassert_eq!(datetime!(2021-01-01%200%3A00).sunday_based_week()%2C%200)%3B%0A%7D&edition=2021">Run</a></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.monday_based_week" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#210-212">source</a><h4 class="code-header">pub const fn <a href="#method.monday_based_week" class="fnname">monday_based_week</a>(self) -> u8</h4></section></summary><div class="docblock"><p>Get the week number where week 1 begins on the first Monday.</p> |
| <p>The returned value will always be in the range <code>0..=53</code>.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">01</span>-<span class="number">01 0</span>:<span class="number">00</span>).monday_based_week(), <span class="number">0</span>); |
| <span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2020</span>-<span class="number">01</span>-<span class="number">01 0</span>:<span class="number">00</span>).monday_based_week(), <span class="number">0</span>); |
| <span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2020</span>-<span class="number">12</span>-<span class="number">31 0</span>:<span class="number">00</span>).monday_based_week(), <span class="number">52</span>); |
| <span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2021</span>-<span class="number">01</span>-<span class="number">01 0</span>:<span class="number">00</span>).monday_based_week(), <span class="number">0</span>);</code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time_macros%3A%3Adatetime%3B%0Aassert_eq!(datetime!(2019-01-01%200%3A00).monday_based_week()%2C%200)%3B%0Aassert_eq!(datetime!(2020-01-01%200%3A00).monday_based_week()%2C%200)%3B%0Aassert_eq!(datetime!(2020-12-31%200%3A00).monday_based_week()%2C%2052)%3B%0Aassert_eq!(datetime!(2021-01-01%200%3A00).monday_based_week()%2C%200)%3B%0A%7D&edition=2021">Run</a></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.to_calendar_date" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#224-226">source</a><h4 class="code-header">pub const fn <a href="#method.to_calendar_date" class="fnname">to_calendar_date</a>(self) -> (i32, <a class="enum" href="enum.Month.html" title="enum time::Month">Month</a>, u8)</h4></section></summary><div class="docblock"><p>Get the year, month, and day.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>( |
| <span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">01</span>-<span class="number">01 0</span>:<span class="number">00</span>).to_calendar_date(), |
| (<span class="number">2019</span>, Month::January, <span class="number">1</span>) |
| );</code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time%3A%3AMonth%3B%0Ause%20time_macros%3A%3Adatetime%3B%0Aassert_eq!(%0A%20%20%20%20datetime!(2019-01-01%200%3A00).to_calendar_date()%2C%0A%20%20%20%20(2019%2C%20Month%3A%3AJanuary%2C%201)%0A)%3B%0A%7D&edition=2021">Run</a></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.to_ordinal_date" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#234-236">source</a><h4 class="code-header">pub const fn <a href="#method.to_ordinal_date" class="fnname">to_ordinal_date</a>(self) -> (i32, u16)</h4></section></summary><div class="docblock"><p>Get the year and ordinal day number.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">01</span>-<span class="number">01 0</span>:<span class="number">00</span>).to_ordinal_date(), (<span class="number">2019</span>, <span class="number">1</span>));</code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time_macros%3A%3Adatetime%3B%0Aassert_eq!(datetime!(2019-01-01%200%3A00).to_ordinal_date()%2C%20(2019%2C%201))%3B%0A%7D&edition=2021">Run</a></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.to_iso_week_date" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#264-266">source</a><h4 class="code-header">pub const fn <a href="#method.to_iso_week_date" class="fnname">to_iso_week_date</a>(self) -> (i32, u8, <a class="enum" href="enum.Weekday.html" title="enum time::Weekday">Weekday</a>)</h4></section></summary><div class="docblock"><p>Get the ISO 8601 year, week number, and weekday.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>( |
| <span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">01</span>-<span class="number">01 0</span>:<span class="number">00</span>).to_iso_week_date(), |
| (<span class="number">2019</span>, <span class="number">1</span>, Tuesday) |
| ); |
| <span class="macro">assert_eq!</span>( |
| <span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">10</span>-<span class="number">04 0</span>:<span class="number">00</span>).to_iso_week_date(), |
| (<span class="number">2019</span>, <span class="number">40</span>, Friday) |
| ); |
| <span class="macro">assert_eq!</span>( |
| <span class="macro">datetime!</span>(<span class="number">2020</span>-<span class="number">01</span>-<span class="number">01 0</span>:<span class="number">00</span>).to_iso_week_date(), |
| (<span class="number">2020</span>, <span class="number">1</span>, Wednesday) |
| ); |
| <span class="macro">assert_eq!</span>( |
| <span class="macro">datetime!</span>(<span class="number">2020</span>-<span class="number">12</span>-<span class="number">31 0</span>:<span class="number">00</span>).to_iso_week_date(), |
| (<span class="number">2020</span>, <span class="number">53</span>, Thursday) |
| ); |
| <span class="macro">assert_eq!</span>( |
| <span class="macro">datetime!</span>(<span class="number">2021</span>-<span class="number">01</span>-<span class="number">01 0</span>:<span class="number">00</span>).to_iso_week_date(), |
| (<span class="number">2020</span>, <span class="number">53</span>, Friday) |
| );</code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time%3A%3AWeekday%3A%3A*%3B%0Ause%20time_macros%3A%3Adatetime%3B%0Aassert_eq!(%0A%20%20%20%20datetime!(2019-01-01%200%3A00).to_iso_week_date()%2C%0A%20%20%20%20(2019%2C%201%2C%20Tuesday)%0A)%3B%0Aassert_eq!(%0A%20%20%20%20datetime!(2019-10-04%200%3A00).to_iso_week_date()%2C%0A%20%20%20%20(2019%2C%2040%2C%20Friday)%0A)%3B%0Aassert_eq!(%0A%20%20%20%20datetime!(2020-01-01%200%3A00).to_iso_week_date()%2C%0A%20%20%20%20(2020%2C%201%2C%20Wednesday)%0A)%3B%0Aassert_eq!(%0A%20%20%20%20datetime!(2020-12-31%200%3A00).to_iso_week_date()%2C%0A%20%20%20%20(2020%2C%2053%2C%20Thursday)%0A)%3B%0Aassert_eq!(%0A%20%20%20%20datetime!(2021-01-01%200%3A00).to_iso_week_date()%2C%0A%20%20%20%20(2020%2C%2053%2C%20Friday)%0A)%3B%0A%7D&edition=2021">Run</a></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.weekday" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#286-288">source</a><h4 class="code-header">pub const fn <a href="#method.weekday" class="fnname">weekday</a>(self) -> <a class="enum" href="enum.Weekday.html" title="enum time::Weekday">Weekday</a></h4></section></summary><div class="docblock"><p>Get the weekday.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">01</span>-<span class="number">01 0</span>:<span class="number">00</span>).weekday(), Tuesday); |
| <span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">02</span>-<span class="number">01 0</span>:<span class="number">00</span>).weekday(), Friday); |
| <span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">03</span>-<span class="number">01 0</span>:<span class="number">00</span>).weekday(), Friday); |
| <span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">04</span>-<span class="number">01 0</span>:<span class="number">00</span>).weekday(), Monday); |
| <span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">05</span>-<span class="number">01 0</span>:<span class="number">00</span>).weekday(), Wednesday); |
| <span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">06</span>-<span class="number">01 0</span>:<span class="number">00</span>).weekday(), Saturday); |
| <span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">07</span>-<span class="number">01 0</span>:<span class="number">00</span>).weekday(), Monday); |
| <span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">08</span>-<span class="number">01 0</span>:<span class="number">00</span>).weekday(), Thursday); |
| <span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">09</span>-<span class="number">01 0</span>:<span class="number">00</span>).weekday(), Sunday); |
| <span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">10</span>-<span class="number">01 0</span>:<span class="number">00</span>).weekday(), Tuesday); |
| <span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">11</span>-<span class="number">01 0</span>:<span class="number">00</span>).weekday(), Friday); |
| <span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">12</span>-<span class="number">01 0</span>:<span class="number">00</span>).weekday(), Sunday);</code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time%3A%3AWeekday%3A%3A*%3B%0Ause%20time_macros%3A%3Adatetime%3B%0Aassert_eq!(datetime!(2019-01-01%200%3A00).weekday()%2C%20Tuesday)%3B%0Aassert_eq!(datetime!(2019-02-01%200%3A00).weekday()%2C%20Friday)%3B%0Aassert_eq!(datetime!(2019-03-01%200%3A00).weekday()%2C%20Friday)%3B%0Aassert_eq!(datetime!(2019-04-01%200%3A00).weekday()%2C%20Monday)%3B%0Aassert_eq!(datetime!(2019-05-01%200%3A00).weekday()%2C%20Wednesday)%3B%0Aassert_eq!(datetime!(2019-06-01%200%3A00).weekday()%2C%20Saturday)%3B%0Aassert_eq!(datetime!(2019-07-01%200%3A00).weekday()%2C%20Monday)%3B%0Aassert_eq!(datetime!(2019-08-01%200%3A00).weekday()%2C%20Thursday)%3B%0Aassert_eq!(datetime!(2019-09-01%200%3A00).weekday()%2C%20Sunday)%3B%0Aassert_eq!(datetime!(2019-10-01%200%3A00).weekday()%2C%20Tuesday)%3B%0Aassert_eq!(datetime!(2019-11-01%200%3A00).weekday()%2C%20Friday)%3B%0Aassert_eq!(datetime!(2019-12-01%200%3A00).weekday()%2C%20Sunday)%3B%0A%7D&edition=2021">Run</a></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.to_julian_day" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#302-304">source</a><h4 class="code-header">pub const fn <a href="#method.to_julian_day" class="fnname">to_julian_day</a>(self) -> i32</h4></section></summary><div class="docblock"><p>Get the Julian day for the date. The time is not taken into account for this calculation.</p> |
| <p>The algorithm to perform this conversion is derived from one provided by Peter Baum; it is |
| freely available <a href="https://www.researchgate.net/publication/316558298_Date_Algorithms">here</a>.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(-<span class="number">4713</span>-<span class="number">11</span>-<span class="number">24 0</span>:<span class="number">00</span>).to_julian_day(), <span class="number">0</span>); |
| <span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2000</span>-<span class="number">01</span>-<span class="number">01 0</span>:<span class="number">00</span>).to_julian_day(), <span class="number">2_451_545</span>); |
| <span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">01</span>-<span class="number">01 0</span>:<span class="number">00</span>).to_julian_day(), <span class="number">2_458_485</span>); |
| <span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">12</span>-<span class="number">31 0</span>:<span class="number">00</span>).to_julian_day(), <span class="number">2_458_849</span>);</code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time_macros%3A%3Adatetime%3B%0Aassert_eq!(datetime!(-4713-11-24%200%3A00).to_julian_day()%2C%200)%3B%0Aassert_eq!(datetime!(2000-01-01%200%3A00).to_julian_day()%2C%202_451_545)%3B%0Aassert_eq!(datetime!(2019-01-01%200%3A00).to_julian_day()%2C%202_458_485)%3B%0Aassert_eq!(datetime!(2019-12-31%200%3A00).to_julian_day()%2C%202_458_849)%3B%0A%7D&edition=2021">Run</a></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.as_hms" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#315-317">source</a><h4 class="code-header">pub const fn <a href="#method.as_hms" class="fnname">as_hms</a>(self) -> (u8, u8, u8)</h4></section></summary><div class="docblock"><p>Get the clock hour, minute, and second.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2020</span>-<span class="number">01</span>-<span class="number">01 0</span>:<span class="number">00</span>:<span class="number">00</span>).as_hms(), (<span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>)); |
| <span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2020</span>-<span class="number">01</span>-<span class="number">01 23</span>:<span class="number">59</span>:<span class="number">59</span>).as_hms(), (<span class="number">23</span>, <span class="number">59</span>, <span class="number">59</span>));</code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time_macros%3A%3Adatetime%3B%0Aassert_eq!(datetime!(2020-01-01%200%3A00%3A00).as_hms()%2C%20(0%2C%200%2C%200))%3B%0Aassert_eq!(datetime!(2020-01-01%2023%3A59%3A59).as_hms()%2C%20(23%2C%2059%2C%2059))%3B%0A%7D&edition=2021">Run</a></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.as_hms_milli" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#329-331">source</a><h4 class="code-header">pub const fn <a href="#method.as_hms_milli" class="fnname">as_hms_milli</a>(self) -> (u8, u8, u8, u16)</h4></section></summary><div class="docblock"><p>Get the clock hour, minute, second, and millisecond.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2020</span>-<span class="number">01</span>-<span class="number">01 0</span>:<span class="number">00</span>:<span class="number">00</span>).as_hms_milli(), (<span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>)); |
| <span class="macro">assert_eq!</span>( |
| <span class="macro">datetime!</span>(<span class="number">2020</span>-<span class="number">01</span>-<span class="number">01 23</span>:<span class="number">59</span>:<span class="number">59.999</span>).as_hms_milli(), |
| (<span class="number">23</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">999</span>) |
| );</code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time_macros%3A%3Adatetime%3B%0Aassert_eq!(datetime!(2020-01-01%200%3A00%3A00).as_hms_milli()%2C%20(0%2C%200%2C%200%2C%200))%3B%0Aassert_eq!(%0A%20%20%20%20datetime!(2020-01-01%2023%3A59%3A59.999).as_hms_milli()%2C%0A%20%20%20%20(23%2C%2059%2C%2059%2C%20999)%0A)%3B%0A%7D&edition=2021">Run</a></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.as_hms_micro" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#343-345">source</a><h4 class="code-header">pub const fn <a href="#method.as_hms_micro" class="fnname">as_hms_micro</a>(self) -> (u8, u8, u8, u32)</h4></section></summary><div class="docblock"><p>Get the clock hour, minute, second, and microsecond.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2020</span>-<span class="number">01</span>-<span class="number">01 0</span>:<span class="number">00</span>:<span class="number">00</span>).as_hms_micro(), (<span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>)); |
| <span class="macro">assert_eq!</span>( |
| <span class="macro">datetime!</span>(<span class="number">2020</span>-<span class="number">01</span>-<span class="number">01 23</span>:<span class="number">59</span>:<span class="number">59.999_999</span>).as_hms_micro(), |
| (<span class="number">23</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">999_999</span>) |
| );</code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time_macros%3A%3Adatetime%3B%0Aassert_eq!(datetime!(2020-01-01%200%3A00%3A00).as_hms_micro()%2C%20(0%2C%200%2C%200%2C%200))%3B%0Aassert_eq!(%0A%20%20%20%20datetime!(2020-01-01%2023%3A59%3A59.999_999).as_hms_micro()%2C%0A%20%20%20%20(23%2C%2059%2C%2059%2C%20999_999)%0A)%3B%0A%7D&edition=2021">Run</a></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.as_hms_nano" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#357-359">source</a><h4 class="code-header">pub const fn <a href="#method.as_hms_nano" class="fnname">as_hms_nano</a>(self) -> (u8, u8, u8, u32)</h4></section></summary><div class="docblock"><p>Get the clock hour, minute, second, and nanosecond.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2020</span>-<span class="number">01</span>-<span class="number">01 0</span>:<span class="number">00</span>:<span class="number">00</span>).as_hms_nano(), (<span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>)); |
| <span class="macro">assert_eq!</span>( |
| <span class="macro">datetime!</span>(<span class="number">2020</span>-<span class="number">01</span>-<span class="number">01 23</span>:<span class="number">59</span>:<span class="number">59.999_999_999</span>).as_hms_nano(), |
| (<span class="number">23</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">999_999_999</span>) |
| );</code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time_macros%3A%3Adatetime%3B%0Aassert_eq!(datetime!(2020-01-01%200%3A00%3A00).as_hms_nano()%2C%20(0%2C%200%2C%200%2C%200))%3B%0Aassert_eq!(%0A%20%20%20%20datetime!(2020-01-01%2023%3A59%3A59.999_999_999).as_hms_nano()%2C%0A%20%20%20%20(23%2C%2059%2C%2059%2C%20999_999_999)%0A)%3B%0A%7D&edition=2021">Run</a></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.hour" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#370-372">source</a><h4 class="code-header">pub const fn <a href="#method.hour" class="fnname">hour</a>(self) -> u8</h4></section></summary><div class="docblock"><p>Get the clock hour.</p> |
| <p>The returned value will always be in the range <code>0..24</code>.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">01</span>-<span class="number">01 0</span>:<span class="number">00</span>).hour(), <span class="number">0</span>); |
| <span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">01</span>-<span class="number">01 23</span>:<span class="number">59</span>:<span class="number">59</span>).hour(), <span class="number">23</span>);</code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time_macros%3A%3Adatetime%3B%0Aassert_eq!(datetime!(2019-01-01%200%3A00).hour()%2C%200)%3B%0Aassert_eq!(datetime!(2019-01-01%2023%3A59%3A59).hour()%2C%2023)%3B%0A%7D&edition=2021">Run</a></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.minute" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#383-385">source</a><h4 class="code-header">pub const fn <a href="#method.minute" class="fnname">minute</a>(self) -> u8</h4></section></summary><div class="docblock"><p>Get the minute within the hour.</p> |
| <p>The returned value will always be in the range <code>0..60</code>.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">01</span>-<span class="number">01 0</span>:<span class="number">00</span>).minute(), <span class="number">0</span>); |
| <span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">01</span>-<span class="number">01 23</span>:<span class="number">59</span>:<span class="number">59</span>).minute(), <span class="number">59</span>);</code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time_macros%3A%3Adatetime%3B%0Aassert_eq!(datetime!(2019-01-01%200%3A00).minute()%2C%200)%3B%0Aassert_eq!(datetime!(2019-01-01%2023%3A59%3A59).minute()%2C%2059)%3B%0A%7D&edition=2021">Run</a></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.second" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#396-398">source</a><h4 class="code-header">pub const fn <a href="#method.second" class="fnname">second</a>(self) -> u8</h4></section></summary><div class="docblock"><p>Get the second within the minute.</p> |
| <p>The returned value will always be in the range <code>0..60</code>.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">01</span>-<span class="number">01 0</span>:<span class="number">00</span>).second(), <span class="number">0</span>); |
| <span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">01</span>-<span class="number">01 23</span>:<span class="number">59</span>:<span class="number">59</span>).second(), <span class="number">59</span>);</code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time_macros%3A%3Adatetime%3B%0Aassert_eq!(datetime!(2019-01-01%200%3A00).second()%2C%200)%3B%0Aassert_eq!(datetime!(2019-01-01%2023%3A59%3A59).second()%2C%2059)%3B%0A%7D&edition=2021">Run</a></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.millisecond" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#409-411">source</a><h4 class="code-header">pub const fn <a href="#method.millisecond" class="fnname">millisecond</a>(self) -> u16</h4></section></summary><div class="docblock"><p>Get the milliseconds within the second.</p> |
| <p>The returned value will always be in the range <code>0..1_000</code>.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">01</span>-<span class="number">01 0</span>:<span class="number">00</span>).millisecond(), <span class="number">0</span>); |
| <span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">01</span>-<span class="number">01 23</span>:<span class="number">59</span>:<span class="number">59.999</span>).millisecond(), <span class="number">999</span>);</code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time_macros%3A%3Adatetime%3B%0Aassert_eq!(datetime!(2019-01-01%200%3A00).millisecond()%2C%200)%3B%0Aassert_eq!(datetime!(2019-01-01%2023%3A59%3A59.999).millisecond()%2C%20999)%3B%0A%7D&edition=2021">Run</a></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.microsecond" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#425-427">source</a><h4 class="code-header">pub const fn <a href="#method.microsecond" class="fnname">microsecond</a>(self) -> u32</h4></section></summary><div class="docblock"><p>Get the microseconds within the second.</p> |
| <p>The returned value will always be in the range <code>0..1_000_000</code>.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">01</span>-<span class="number">01 0</span>:<span class="number">00</span>).microsecond(), <span class="number">0</span>); |
| <span class="macro">assert_eq!</span>( |
| <span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">01</span>-<span class="number">01 23</span>:<span class="number">59</span>:<span class="number">59.999_999</span>).microsecond(), |
| <span class="number">999_999 |
| </span>);</code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time_macros%3A%3Adatetime%3B%0Aassert_eq!(datetime!(2019-01-01%200%3A00).microsecond()%2C%200)%3B%0Aassert_eq!(%0A%20%20%20%20datetime!(2019-01-01%2023%3A59%3A59.999_999).microsecond()%2C%0A%20%20%20%20999_999%0A)%3B%0A%7D&edition=2021">Run</a></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.nanosecond" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#441-443">source</a><h4 class="code-header">pub const fn <a href="#method.nanosecond" class="fnname">nanosecond</a>(self) -> u32</h4></section></summary><div class="docblock"><p>Get the nanoseconds within the second.</p> |
| <p>The returned value will always be in the range <code>0..1_000_000_000</code>.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(<span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">01</span>-<span class="number">01 0</span>:<span class="number">00</span>).nanosecond(), <span class="number">0</span>); |
| <span class="macro">assert_eq!</span>( |
| <span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">01</span>-<span class="number">01 23</span>:<span class="number">59</span>:<span class="number">59.999_999_999</span>).nanosecond(), |
| <span class="number">999_999_999</span>, |
| );</code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time_macros%3A%3Adatetime%3B%0Aassert_eq!(datetime!(2019-01-01%200%3A00).nanosecond()%2C%200)%3B%0Aassert_eq!(%0A%20%20%20%20datetime!(2019-01-01%2023%3A59%3A59.999_999_999).nanosecond()%2C%0A%20%20%20%20999_999_999%2C%0A)%3B%0A%7D&edition=2021">Run</a></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.assume_offset" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#465-467">source</a><h4 class="code-header">pub const fn <a href="#method.assume_offset" class="fnname">assume_offset</a>(self, offset: <a class="struct" href="struct.UtcOffset.html" title="struct time::UtcOffset">UtcOffset</a>) -> <a class="struct" href="struct.OffsetDateTime.html" title="struct time::OffsetDateTime">OffsetDateTime</a></h4></section></summary><div class="docblock"><p>Assuming that the existing <code>PrimitiveDateTime</code> represents a moment in the provided |
| <a href="struct.UtcOffset.html" title="UtcOffset"><code>UtcOffset</code></a>, return an <a href="struct.OffsetDateTime.html" title="OffsetDateTime"><code>OffsetDateTime</code></a>.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>( |
| <span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">01</span>-<span class="number">01 0</span>:<span class="number">00</span>) |
| .assume_offset(<span class="macro">offset!</span>(UTC)) |
| .unix_timestamp(), |
| <span class="number">1_546_300_800</span>, |
| ); |
| <span class="macro">assert_eq!</span>( |
| <span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">01</span>-<span class="number">01 0</span>:<span class="number">00</span>) |
| .assume_offset(<span class="macro">offset!</span>(-<span class="number">1</span>)) |
| .unix_timestamp(), |
| <span class="number">1_546_304_400</span>, |
| );</code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time_macros%3A%3A%7Bdatetime%2C%20offset%7D%3B%0Aassert_eq!(%0A%20%20%20%20datetime!(2019-01-01%200%3A00)%0A%20%20%20%20%20%20%20%20.assume_offset(offset!(UTC))%0A%20%20%20%20%20%20%20%20.unix_timestamp()%2C%0A%20%20%20%201_546_300_800%2C%0A)%3B%0Aassert_eq!(%0A%20%20%20%20datetime!(2019-01-01%200%3A00)%0A%20%20%20%20%20%20%20%20.assume_offset(offset!(-1))%0A%20%20%20%20%20%20%20%20.unix_timestamp()%2C%0A%20%20%20%201_546_304_400%2C%0A)%3B%0A%7D&edition=2021">Run</a></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.assume_utc" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#479-481">source</a><h4 class="code-header">pub const fn <a href="#method.assume_utc" class="fnname">assume_utc</a>(self) -> <a class="struct" href="struct.OffsetDateTime.html" title="struct time::OffsetDateTime">OffsetDateTime</a></h4></section></summary><div class="docblock"><p>Assuming that the existing <code>PrimitiveDateTime</code> represents a moment in UTC, return an |
| <a href="struct.OffsetDateTime.html" title="OffsetDateTime"><code>OffsetDateTime</code></a>.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>( |
| <span class="macro">datetime!</span>(<span class="number">2019</span>-<span class="number">01</span>-<span class="number">01 0</span>:<span class="number">00</span>).assume_utc().unix_timestamp(), |
| <span class="number">1_546_300_800</span>, |
| );</code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time_macros%3A%3Adatetime%3B%0Aassert_eq!(%0A%20%20%20%20datetime!(2019-01-01%200%3A00).assume_utc().unix_timestamp()%2C%0A%20%20%20%201_546_300_800%2C%0A)%3B%0A%7D&edition=2021">Run</a></div> |
| </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/time/primitive_date_time.rs.html#501-503">source</a><h4 class="code-header">pub const fn <a href="#method.checked_add" class="fnname">checked_add</a>(self, duration: <a class="struct" href="struct.Duration.html" title="struct time::Duration">Duration</a>) -> Option<Self></h4></section></summary><div class="docblock"><p>Computes <code>self + duration</code>, returning <code>None</code> if an overflow occurred.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>datetime = Date::MIN.midnight(); |
| <span class="macro">assert_eq!</span>(datetime.checked_add((-<span class="number">2</span>).days()), <span class="prelude-val">None</span>); |
| |
| <span class="kw">let </span>datetime = Date::MAX.midnight(); |
| <span class="macro">assert_eq!</span>(datetime.checked_add(<span class="number">1</span>.days()), <span class="prelude-val">None</span>); |
| |
| <span class="macro">assert_eq!</span>( |
| <span class="macro">datetime!</span>(<span class="number">2019 </span>- <span class="number">11 </span>- <span class="number">25 15</span>:<span class="number">30</span>).checked_add(<span class="number">27</span>.hours()), |
| <span class="prelude-val">Some</span>(<span class="macro">datetime!</span>(<span class="number">2019 </span>- <span class="number">11 </span>- <span class="number">26 18</span>:<span class="number">30</span>)) |
| );</code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time%3A%3A%7BDate%2C%20ext%3A%3ANumericalDuration%7D%3B%0Ause%20time_macros%3A%3Adatetime%3B%0Alet%20datetime%20%3D%20Date%3A%3AMIN.midnight()%3B%0Aassert_eq!(datetime.checked_add((-2).days())%2C%20None)%3B%0A%0Alet%20datetime%20%3D%20Date%3A%3AMAX.midnight()%3B%0Aassert_eq!(datetime.checked_add(1.days())%2C%20None)%3B%0A%0Aassert_eq!(%0A%20%20%20%20datetime!(2019%20-%2011%20-%2025%2015%3A30).checked_add(27.hours())%2C%0A%20%20%20%20Some(datetime!(2019%20-%2011%20-%2026%2018%3A30))%0A)%3B%0A%7D&edition=2021">Run</a></div> |
| </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/time/primitive_date_time.rs.html#521-523">source</a><h4 class="code-header">pub const fn <a href="#method.checked_sub" class="fnname">checked_sub</a>(self, duration: <a class="struct" href="struct.Duration.html" title="struct time::Duration">Duration</a>) -> Option<Self></h4></section></summary><div class="docblock"><p>Computes <code>self - duration</code>, returning <code>None</code> if an overflow occurred.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>datetime = Date::MIN.midnight(); |
| <span class="macro">assert_eq!</span>(datetime.checked_sub(<span class="number">2</span>.days()), <span class="prelude-val">None</span>); |
| |
| <span class="kw">let </span>datetime = Date::MAX.midnight(); |
| <span class="macro">assert_eq!</span>(datetime.checked_sub((-<span class="number">1</span>).days()), <span class="prelude-val">None</span>); |
| |
| <span class="macro">assert_eq!</span>( |
| <span class="macro">datetime!</span>(<span class="number">2019 </span>- <span class="number">11 </span>- <span class="number">25 15</span>:<span class="number">30</span>).checked_sub(<span class="number">27</span>.hours()), |
| <span class="prelude-val">Some</span>(<span class="macro">datetime!</span>(<span class="number">2019 </span>- <span class="number">11 </span>- <span class="number">24 12</span>:<span class="number">30</span>)) |
| );</code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time%3A%3A%7BDate%2C%20ext%3A%3ANumericalDuration%7D%3B%0Ause%20time_macros%3A%3Adatetime%3B%0Alet%20datetime%20%3D%20Date%3A%3AMIN.midnight()%3B%0Aassert_eq!(datetime.checked_sub(2.days())%2C%20None)%3B%0A%0Alet%20datetime%20%3D%20Date%3A%3AMAX.midnight()%3B%0Aassert_eq!(datetime.checked_sub((-1).days())%2C%20None)%3B%0A%0Aassert_eq!(%0A%20%20%20%20datetime!(2019%20-%2011%20-%2025%2015%3A30).checked_sub(27.hours())%2C%0A%20%20%20%20Some(datetime!(2019%20-%2011%20-%2024%2012%3A30))%0A)%3B%0A%7D&edition=2021">Run</a></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.saturating_add" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#547-549">source</a><h4 class="code-header">pub const fn <a href="#method.saturating_add" class="fnname">saturating_add</a>(self, duration: <a class="struct" href="struct.Duration.html" title="struct time::Duration">Duration</a>) -> Self</h4></section></summary><div class="docblock"><p>Computes <code>self + duration</code>, saturating value on overflow.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>( |
| PrimitiveDateTime::MIN.saturating_add((-<span class="number">2</span>).days()), |
| PrimitiveDateTime::MIN |
| ); |
| |
| <span class="macro">assert_eq!</span>( |
| PrimitiveDateTime::MAX.saturating_add(<span class="number">2</span>.days()), |
| PrimitiveDateTime::MAX |
| ); |
| |
| <span class="macro">assert_eq!</span>( |
| <span class="macro">datetime!</span>(<span class="number">2019 </span>- <span class="number">11 </span>- <span class="number">25 15</span>:<span class="number">30</span>).saturating_add(<span class="number">27</span>.hours()), |
| <span class="macro">datetime!</span>(<span class="number">2019 </span>- <span class="number">11 </span>- <span class="number">26 18</span>:<span class="number">30</span>) |
| );</code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time%3A%3A%7BPrimitiveDateTime%2C%20ext%3A%3ANumericalDuration%7D%3B%0Ause%20time_macros%3A%3Adatetime%3B%0Aassert_eq!(%0A%20%20%20%20PrimitiveDateTime%3A%3AMIN.saturating_add((-2).days())%2C%0A%20%20%20%20PrimitiveDateTime%3A%3AMIN%0A)%3B%0A%0Aassert_eq!(%0A%20%20%20%20PrimitiveDateTime%3A%3AMAX.saturating_add(2.days())%2C%0A%20%20%20%20PrimitiveDateTime%3A%3AMAX%0A)%3B%0A%0Aassert_eq!(%0A%20%20%20%20datetime!(2019%20-%2011%20-%2025%2015%3A30).saturating_add(27.hours())%2C%0A%20%20%20%20datetime!(2019%20-%2011%20-%2026%2018%3A30)%0A)%3B%0A%7D&edition=2021">Run</a></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.saturating_sub" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#571-573">source</a><h4 class="code-header">pub const fn <a href="#method.saturating_sub" class="fnname">saturating_sub</a>(self, duration: <a class="struct" href="struct.Duration.html" title="struct time::Duration">Duration</a>) -> Self</h4></section></summary><div class="docblock"><p>Computes <code>self - duration</code>, saturating value on overflow.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>( |
| PrimitiveDateTime::MIN.saturating_sub(<span class="number">2</span>.days()), |
| PrimitiveDateTime::MIN |
| ); |
| |
| <span class="macro">assert_eq!</span>( |
| PrimitiveDateTime::MAX.saturating_sub((-<span class="number">2</span>).days()), |
| PrimitiveDateTime::MAX |
| ); |
| |
| <span class="macro">assert_eq!</span>( |
| <span class="macro">datetime!</span>(<span class="number">2019 </span>- <span class="number">11 </span>- <span class="number">25 15</span>:<span class="number">30</span>).saturating_sub(<span class="number">27</span>.hours()), |
| <span class="macro">datetime!</span>(<span class="number">2019 </span>- <span class="number">11 </span>- <span class="number">24 12</span>:<span class="number">30</span>) |
| );</code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time%3A%3A%7BPrimitiveDateTime%2C%20ext%3A%3ANumericalDuration%7D%3B%0Ause%20time_macros%3A%3Adatetime%3B%0Aassert_eq!(%0A%20%20%20%20PrimitiveDateTime%3A%3AMIN.saturating_sub(2.days())%2C%0A%20%20%20%20PrimitiveDateTime%3A%3AMIN%0A)%3B%0A%0Aassert_eq!(%0A%20%20%20%20PrimitiveDateTime%3A%3AMAX.saturating_sub((-2).days())%2C%0A%20%20%20%20PrimitiveDateTime%3A%3AMAX%0A)%3B%0A%0Aassert_eq!(%0A%20%20%20%20datetime!(2019%20-%2011%20-%2025%2015%3A30).saturating_sub(27.hours())%2C%0A%20%20%20%20datetime!(2019%20-%2011%20-%2024%2012%3A30)%0A)%3B%0A%7D&edition=2021">Run</a></div> |
| </div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-PrimitiveDateTime-1" class="impl has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#579-751">source</a><a href="#impl-PrimitiveDateTime-1" class="anchor"></a><h3 class="code-header">impl <a class="struct" href="struct.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</a></h3></section></summary><div class="docblock"><p>Methods that replace part of the <code>PrimitiveDateTime</code>.</p> |
| </div><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.replace_time" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#590-592">source</a><h4 class="code-header">pub const fn <a href="#method.replace_time" class="fnname">replace_time</a>(self, time: <a class="struct" href="struct.Time.html" title="struct time::Time">Time</a>) -> Self</h4></section></summary><div class="docblock"><p>Replace the time, preserving the date.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>( |
| <span class="macro">datetime!</span>(<span class="number">2020</span>-<span class="number">01</span>-<span class="number">01 17</span>:<span class="number">00</span>).replace_time(<span class="macro">time!</span>(<span class="number">5</span>:<span class="number">00</span>)), |
| <span class="macro">datetime!</span>(<span class="number">2020</span>-<span class="number">01</span>-<span class="number">01 5</span>:<span class="number">00</span>) |
| );</code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time_macros%3A%3A%7Bdatetime%2C%20time%7D%3B%0Aassert_eq!(%0A%20%20%20%20datetime!(2020-01-01%2017%3A00).replace_time(time!(5%3A00))%2C%0A%20%20%20%20datetime!(2020-01-01%205%3A00)%0A)%3B%0A%7D&edition=2021">Run</a></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.replace_date" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#604-606">source</a><h4 class="code-header">pub const fn <a href="#method.replace_date" class="fnname">replace_date</a>(self, date: <a class="struct" href="struct.Date.html" title="struct time::Date">Date</a>) -> Self</h4></section></summary><div class="docblock"><p>Replace the date, preserving the time.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>( |
| <span class="macro">datetime!</span>(<span class="number">2020</span>-<span class="number">01</span>-<span class="number">01 12</span>:<span class="number">00</span>).replace_date(<span class="macro">date!</span>(<span class="number">2020</span>-<span class="number">01</span>-<span class="number">30</span>)), |
| <span class="macro">datetime!</span>(<span class="number">2020</span>-<span class="number">01</span>-<span class="number">30 12</span>:<span class="number">00</span>) |
| );</code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time_macros%3A%3A%7Bdatetime%2C%20date%7D%3B%0Aassert_eq!(%0A%20%20%20%20datetime!(2020-01-01%2012%3A00).replace_date(date!(2020-01-30))%2C%0A%20%20%20%20datetime!(2020-01-30%2012%3A00)%0A)%3B%0A%7D&edition=2021">Run</a></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.replace_year" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#620-622">source</a><h4 class="code-header">pub const fn <a href="#method.replace_year" class="fnname">replace_year</a>(self, year: i32) -> Result<Self, <a class="struct" href="error/struct.ComponentRange.html" title="struct time::error::ComponentRange">ComponentRange</a>></h4></section></summary><div class="docblock"><p>Replace the year. The month and day will be unchanged.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>( |
| <span class="macro">datetime!</span>(<span class="number">2022 </span>- <span class="number">02 </span>- <span class="number">18 12</span>:<span class="number">00</span>).replace_year(<span class="number">2019</span>), |
| <span class="prelude-val">Ok</span>(<span class="macro">datetime!</span>(<span class="number">2019 </span>- <span class="number">02 </span>- <span class="number">18 12</span>:<span class="number">00</span>)) |
| ); |
| <span class="macro">assert!</span>(<span class="macro">datetime!</span>(<span class="number">2022 </span>- <span class="number">02 </span>- <span class="number">18 12</span>:<span class="number">00</span>).replace_year(-<span class="number">1_000_000_000</span>).is_err()); <span class="comment">// -1_000_000_000 isn't a valid year |
| </span><span class="macro">assert!</span>(<span class="macro">datetime!</span>(<span class="number">2022 </span>- <span class="number">02 </span>- <span class="number">18 12</span>:<span class="number">00</span>).replace_year(<span class="number">1_000_000_000</span>).is_err()); <span class="comment">// 1_000_000_000 isn't a valid year</span></code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time_macros%3A%3Adatetime%3B%0Aassert_eq!(%0A%20%20%20%20datetime!(2022%20-%2002%20-%2018%2012%3A00).replace_year(2019)%2C%0A%20%20%20%20Ok(datetime!(2019%20-%2002%20-%2018%2012%3A00))%0A)%3B%0Aassert!(datetime!(2022%20-%2002%20-%2018%2012%3A00).replace_year(-1_000_000_000).is_err())%3B%20%2F%2F%20-1_000_000_000%20isn't%20a%20valid%20year%0Aassert!(datetime!(2022%20-%2002%20-%2018%2012%3A00).replace_year(1_000_000_000).is_err())%3B%20%2F%2F%201_000_000_000%20isn't%20a%20valid%20year%0A%7D&edition=2021">Run</a></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.replace_month" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#636-638">source</a><h4 class="code-header">pub const fn <a href="#method.replace_month" class="fnname">replace_month</a>(self, month: <a class="enum" href="enum.Month.html" title="enum time::Month">Month</a>) -> Result<Self, <a class="struct" href="error/struct.ComponentRange.html" title="struct time::error::ComponentRange">ComponentRange</a>></h4></section></summary><div class="docblock"><p>Replace the month of the year.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>( |
| <span class="macro">datetime!</span>(<span class="number">2022 </span>- <span class="number">02 </span>- <span class="number">18 12</span>:<span class="number">00</span>).replace_month(Month::January), |
| <span class="prelude-val">Ok</span>(<span class="macro">datetime!</span>(<span class="number">2022 </span>- <span class="number">01 </span>- <span class="number">18 12</span>:<span class="number">00</span>)) |
| ); |
| <span class="macro">assert!</span>(<span class="macro">datetime!</span>(<span class="number">2022 </span>- <span class="number">01 </span>- <span class="number">30 12</span>:<span class="number">00</span>).replace_month(Month::February).is_err()); <span class="comment">// 30 isn't a valid day in February</span></code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time_macros%3A%3Adatetime%3B%0Ause%20time%3A%3AMonth%3B%0Aassert_eq!(%0A%20%20%20%20datetime!(2022%20-%2002%20-%2018%2012%3A00).replace_month(Month%3A%3AJanuary)%2C%0A%20%20%20%20Ok(datetime!(2022%20-%2001%20-%2018%2012%3A00))%0A)%3B%0Aassert!(datetime!(2022%20-%2001%20-%2030%2012%3A00).replace_month(Month%3A%3AFebruary).is_err())%3B%20%2F%2F%2030%20isn't%20a%20valid%20day%20in%20February%0A%7D&edition=2021">Run</a></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.replace_day" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#652-654">source</a><h4 class="code-header">pub const fn <a href="#method.replace_day" class="fnname">replace_day</a>(self, day: u8) -> Result<Self, <a class="struct" href="error/struct.ComponentRange.html" title="struct time::error::ComponentRange">ComponentRange</a>></h4></section></summary><div class="docblock"><p>Replace the day of the month.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>( |
| <span class="macro">datetime!</span>(<span class="number">2022 </span>- <span class="number">02 </span>- <span class="number">18 12</span>:<span class="number">00</span>).replace_day(<span class="number">1</span>), |
| <span class="prelude-val">Ok</span>(<span class="macro">datetime!</span>(<span class="number">2022 </span>- <span class="number">02 </span>- <span class="number">01 12</span>:<span class="number">00</span>)) |
| ); |
| <span class="macro">assert!</span>(<span class="macro">datetime!</span>(<span class="number">2022 </span>- <span class="number">02 </span>- <span class="number">18 12</span>:<span class="number">00</span>).replace_day(<span class="number">0</span>).is_err()); <span class="comment">// 00 isn't a valid day |
| </span><span class="macro">assert!</span>(<span class="macro">datetime!</span>(<span class="number">2022 </span>- <span class="number">02 </span>- <span class="number">18 12</span>:<span class="number">00</span>).replace_day(<span class="number">30</span>).is_err()); <span class="comment">// 30 isn't a valid day in February</span></code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time_macros%3A%3Adatetime%3B%0Aassert_eq!(%0A%20%20%20%20datetime!(2022%20-%2002%20-%2018%2012%3A00).replace_day(1)%2C%0A%20%20%20%20Ok(datetime!(2022%20-%2002%20-%2001%2012%3A00))%0A)%3B%0Aassert!(datetime!(2022%20-%2002%20-%2018%2012%3A00).replace_day(0).is_err())%3B%20%2F%2F%2000%20isn't%20a%20valid%20day%0Aassert!(datetime!(2022%20-%2002%20-%2018%2012%3A00).replace_day(30).is_err())%3B%20%2F%2F%2030%20isn't%20a%20valid%20day%20in%20February%0A%7D&edition=2021">Run</a></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.replace_hour" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#667-669">source</a><h4 class="code-header">pub const fn <a href="#method.replace_hour" class="fnname">replace_hour</a>(self, hour: u8) -> Result<Self, <a class="struct" href="error/struct.ComponentRange.html" title="struct time::error::ComponentRange">ComponentRange</a>></h4></section></summary><div class="docblock"><p>Replace the clock hour.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>( |
| <span class="macro">datetime!</span>(<span class="number">2022 </span>- <span class="number">02 </span>- <span class="number">18 01</span>:<span class="number">02</span>:<span class="number">03.004_005_006</span>).replace_hour(<span class="number">7</span>), |
| <span class="prelude-val">Ok</span>(<span class="macro">datetime!</span>(<span class="number">2022 </span>- <span class="number">02 </span>- <span class="number">18 07</span>:<span class="number">02</span>:<span class="number">03.004_005_006</span>)) |
| ); |
| <span class="macro">assert!</span>(<span class="macro">datetime!</span>(<span class="number">2022 </span>- <span class="number">02 </span>- <span class="number">18 01</span>:<span class="number">02</span>:<span class="number">03.004_005_006</span>).replace_hour(<span class="number">24</span>).is_err()); <span class="comment">// 24 isn't a valid hour</span></code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time_macros%3A%3Adatetime%3B%0Aassert_eq!(%0A%20%20%20%20datetime!(2022%20-%2002%20-%2018%2001%3A02%3A03.004_005_006).replace_hour(7)%2C%0A%20%20%20%20Ok(datetime!(2022%20-%2002%20-%2018%2007%3A02%3A03.004_005_006))%0A)%3B%0Aassert!(datetime!(2022%20-%2002%20-%2018%2001%3A02%3A03.004_005_006).replace_hour(24).is_err())%3B%20%2F%2F%2024%20isn't%20a%20valid%20hour%0A%7D&edition=2021">Run</a></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.replace_minute" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#682-684">source</a><h4 class="code-header">pub const fn <a href="#method.replace_minute" class="fnname">replace_minute</a>(self, minute: u8) -> Result<Self, <a class="struct" href="error/struct.ComponentRange.html" title="struct time::error::ComponentRange">ComponentRange</a>></h4></section></summary><div class="docblock"><p>Replace the minutes within the hour.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>( |
| <span class="macro">datetime!</span>(<span class="number">2022 </span>- <span class="number">02 </span>- <span class="number">18 01</span>:<span class="number">02</span>:<span class="number">03.004_005_006</span>).replace_minute(<span class="number">7</span>), |
| <span class="prelude-val">Ok</span>(<span class="macro">datetime!</span>(<span class="number">2022 </span>- <span class="number">02 </span>- <span class="number">18 01</span>:<span class="number">07</span>:<span class="number">03.004_005_006</span>)) |
| ); |
| <span class="macro">assert!</span>(<span class="macro">datetime!</span>(<span class="number">2022 </span>- <span class="number">02 </span>- <span class="number">18 01</span>:<span class="number">02</span>:<span class="number">03.004_005_006</span>).replace_minute(<span class="number">60</span>).is_err()); <span class="comment">// 60 isn't a valid minute</span></code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time_macros%3A%3Adatetime%3B%0Aassert_eq!(%0A%20%20%20%20datetime!(2022%20-%2002%20-%2018%2001%3A02%3A03.004_005_006).replace_minute(7)%2C%0A%20%20%20%20Ok(datetime!(2022%20-%2002%20-%2018%2001%3A07%3A03.004_005_006))%0A)%3B%0Aassert!(datetime!(2022%20-%2002%20-%2018%2001%3A02%3A03.004_005_006).replace_minute(60).is_err())%3B%20%2F%2F%2060%20isn't%20a%20valid%20minute%0A%7D&edition=2021">Run</a></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.replace_second" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#697-699">source</a><h4 class="code-header">pub const fn <a href="#method.replace_second" class="fnname">replace_second</a>(self, second: u8) -> Result<Self, <a class="struct" href="error/struct.ComponentRange.html" title="struct time::error::ComponentRange">ComponentRange</a>></h4></section></summary><div class="docblock"><p>Replace the seconds within the minute.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>( |
| <span class="macro">datetime!</span>(<span class="number">2022 </span>- <span class="number">02 </span>- <span class="number">18 01</span>:<span class="number">02</span>:<span class="number">03.004_005_006</span>).replace_second(<span class="number">7</span>), |
| <span class="prelude-val">Ok</span>(<span class="macro">datetime!</span>(<span class="number">2022 </span>- <span class="number">02 </span>- <span class="number">18 01</span>:<span class="number">02</span>:<span class="number">07.004_005_006</span>)) |
| ); |
| <span class="macro">assert!</span>(<span class="macro">datetime!</span>(<span class="number">2022 </span>- <span class="number">02 </span>- <span class="number">18 01</span>:<span class="number">02</span>:<span class="number">03.004_005_006</span>).replace_second(<span class="number">60</span>).is_err()); <span class="comment">// 60 isn't a valid second</span></code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time_macros%3A%3Adatetime%3B%0Aassert_eq!(%0A%20%20%20%20datetime!(2022%20-%2002%20-%2018%2001%3A02%3A03.004_005_006).replace_second(7)%2C%0A%20%20%20%20Ok(datetime!(2022%20-%2002%20-%2018%2001%3A02%3A07.004_005_006))%0A)%3B%0Aassert!(datetime!(2022%20-%2002%20-%2018%2001%3A02%3A03.004_005_006).replace_second(60).is_err())%3B%20%2F%2F%2060%20isn't%20a%20valid%20second%0A%7D&edition=2021">Run</a></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.replace_millisecond" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#712-717">source</a><h4 class="code-header">pub const fn <a href="#method.replace_millisecond" class="fnname">replace_millisecond</a>(<br> self,<br> millisecond: u16<br>) -> Result<Self, <a class="struct" href="error/struct.ComponentRange.html" title="struct time::error::ComponentRange">ComponentRange</a>></h4></section></summary><div class="docblock"><p>Replace the milliseconds within the second.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>( |
| <span class="macro">datetime!</span>(<span class="number">2022 </span>- <span class="number">02 </span>- <span class="number">18 01</span>:<span class="number">02</span>:<span class="number">03.004_005_006</span>).replace_millisecond(<span class="number">7</span>), |
| <span class="prelude-val">Ok</span>(<span class="macro">datetime!</span>(<span class="number">2022 </span>- <span class="number">02 </span>- <span class="number">18 01</span>:<span class="number">02</span>:<span class="number">03.007</span>)) |
| ); |
| <span class="macro">assert!</span>(<span class="macro">datetime!</span>(<span class="number">2022 </span>- <span class="number">02 </span>- <span class="number">18 01</span>:<span class="number">02</span>:<span class="number">03.004_005_006</span>).replace_millisecond(<span class="number">1_000</span>).is_err()); <span class="comment">// 1_000 isn't a valid millisecond</span></code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time_macros%3A%3Adatetime%3B%0Aassert_eq!(%0A%20%20%20%20datetime!(2022%20-%2002%20-%2018%2001%3A02%3A03.004_005_006).replace_millisecond(7)%2C%0A%20%20%20%20Ok(datetime!(2022%20-%2002%20-%2018%2001%3A02%3A03.007))%0A)%3B%0Aassert!(datetime!(2022%20-%2002%20-%2018%2001%3A02%3A03.004_005_006).replace_millisecond(1_000).is_err())%3B%20%2F%2F%201_000%20isn't%20a%20valid%20millisecond%0A%7D&edition=2021">Run</a></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.replace_microsecond" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#730-735">source</a><h4 class="code-header">pub const fn <a href="#method.replace_microsecond" class="fnname">replace_microsecond</a>(<br> self,<br> microsecond: u32<br>) -> Result<Self, <a class="struct" href="error/struct.ComponentRange.html" title="struct time::error::ComponentRange">ComponentRange</a>></h4></section></summary><div class="docblock"><p>Replace the microseconds within the second.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>( |
| <span class="macro">datetime!</span>(<span class="number">2022 </span>- <span class="number">02 </span>- <span class="number">18 01</span>:<span class="number">02</span>:<span class="number">03.004_005_006</span>).replace_microsecond(<span class="number">7_008</span>), |
| <span class="prelude-val">Ok</span>(<span class="macro">datetime!</span>(<span class="number">2022 </span>- <span class="number">02 </span>- <span class="number">18 01</span>:<span class="number">02</span>:<span class="number">03.007_008</span>)) |
| ); |
| <span class="macro">assert!</span>(<span class="macro">datetime!</span>(<span class="number">2022 </span>- <span class="number">02 </span>- <span class="number">18 01</span>:<span class="number">02</span>:<span class="number">03.004_005_006</span>).replace_microsecond(<span class="number">1_000_000</span>).is_err()); <span class="comment">// 1_000_000 isn't a valid microsecond</span></code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time_macros%3A%3Adatetime%3B%0Aassert_eq!(%0A%20%20%20%20datetime!(2022%20-%2002%20-%2018%2001%3A02%3A03.004_005_006).replace_microsecond(7_008)%2C%0A%20%20%20%20Ok(datetime!(2022%20-%2002%20-%2018%2001%3A02%3A03.007_008))%0A)%3B%0Aassert!(datetime!(2022%20-%2002%20-%2018%2001%3A02%3A03.004_005_006).replace_microsecond(1_000_000).is_err())%3B%20%2F%2F%201_000_000%20isn't%20a%20valid%20microsecond%0A%7D&edition=2021">Run</a></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.replace_nanosecond" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#748-750">source</a><h4 class="code-header">pub const fn <a href="#method.replace_nanosecond" class="fnname">replace_nanosecond</a>(<br> self,<br> nanosecond: u32<br>) -> Result<Self, <a class="struct" href="error/struct.ComponentRange.html" title="struct time::error::ComponentRange">ComponentRange</a>></h4></section></summary><div class="docblock"><p>Replace the nanoseconds within the second.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>( |
| <span class="macro">datetime!</span>(<span class="number">2022 </span>- <span class="number">02 </span>- <span class="number">18 01</span>:<span class="number">02</span>:<span class="number">03.004_005_006</span>).replace_nanosecond(<span class="number">7_008_009</span>), |
| <span class="prelude-val">Ok</span>(<span class="macro">datetime!</span>(<span class="number">2022 </span>- <span class="number">02 </span>- <span class="number">18 01</span>:<span class="number">02</span>:<span class="number">03.007_008_009</span>)) |
| ); |
| <span class="macro">assert!</span>(<span class="macro">datetime!</span>(<span class="number">2022 </span>- <span class="number">02 </span>- <span class="number">18 01</span>:<span class="number">02</span>:<span class="number">03.004_005_006</span>).replace_nanosecond(<span class="number">1_000_000_000</span>).is_err()); <span class="comment">// 1_000_000_000 isn't a valid nanosecond</span></code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%0Ause%20time_macros%3A%3Adatetime%3B%0Aassert_eq!(%0A%20%20%20%20datetime!(2022%20-%2002%20-%2018%2001%3A02%3A03.004_005_006).replace_nanosecond(7_008_009)%2C%0A%20%20%20%20Ok(datetime!(2022%20-%2002%20-%2018%2001%3A02%3A03.007_008_009))%0A)%3B%0Aassert!(datetime!(2022%20-%2002%20-%2018%2001%3A02%3A03.004_005_006).replace_nanosecond(1_000_000_000).is_err())%3B%20%2F%2F%201_000_000_000%20isn't%20a%20valid%20nanosecond%0A%7D&edition=2021">Run</a></div> |
| </div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-PrimitiveDateTime-2" class="impl has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#756-783">source</a><a href="#impl-PrimitiveDateTime-2" class="anchor"></a><h3 class="code-header">impl <a class="struct" href="struct.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.format_into" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#759-765">source</a><h4 class="code-header">pub fn <a href="#method.format_into" class="fnname">format_into</a>(<br> self,<br> output: &mut impl Write,<br> format: &impl <a class="trait" href="formatting/trait.Formattable.html" title="trait time::formatting::Formattable">Formattable</a> + ?Sized<br>) -> Result<usize, <a class="enum" href="error/enum.Format.html" title="enum time::error::Format">Format</a>></h4></section></summary><div class="docblock"><p>Format the <code>PrimitiveDateTime</code> using the provided <a href="format_description/index.html">format |
| description</a>.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.format" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#780-782">source</a><h4 class="code-header">pub fn <a href="#method.format" class="fnname">format</a>(self, format: &impl <a class="trait" href="formatting/trait.Formattable.html" title="trait time::formatting::Formattable">Formattable</a> + ?Sized) -> Result<String, <a class="enum" href="error/enum.Format.html" title="enum time::error::Format">Format</a>></h4></section></summary><div class="docblock"><p>Format the <code>PrimitiveDateTime</code> using the provided <a href="format_description/index.html">format |
| description</a>.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>format = format_description::parse(<span class="string">"[year]-[month]-[day] [hour]:[minute]:[second]"</span>)<span class="question-mark">?</span>; |
| <span class="macro">assert_eq!</span>( |
| <span class="macro">datetime!</span>(<span class="number">2020</span>-<span class="number">01</span>-<span class="number">02 03</span>:<span class="number">04</span>:<span class="number">05</span>).format(<span class="kw-2">&</span>format)<span class="question-mark">?</span>, |
| <span class="string">"2020-01-02 03:04:05" |
| </span>);</code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%20fn%20_inner()%20-%3E%20Result%3C()%2C%20impl%20core%3A%3Afmt%3A%3ADebug%3E%20%7B%0Ause%20time%3A%3Aformat_description%3B%0Ause%20time_macros%3A%3Adatetime%3B%0Alet%20format%20%3D%20format_description%3A%3Aparse(%22%5Byear%5D-%5Bmonth%5D-%5Bday%5D%20%5Bhour%5D%3A%5Bminute%5D%3A%5Bsecond%5D%22)%3F%3B%0Aassert_eq!(%0A%20%20%20%20datetime!(2020-01-02%2003%3A04%3A05).format(%26format)%3F%2C%0A%20%20%20%20%222020-01-02%2003%3A04%3A05%22%0A)%3B%0AOk%3A%3A%3C_%2C%20time%3A%3AError%3E(())%0A%7D%20_inner().unwrap()%20%7D&edition=2021">Run</a></div> |
| </div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-PrimitiveDateTime-3" class="impl has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#786-806">source</a><a href="#impl-PrimitiveDateTime-3" class="anchor"></a><h3 class="code-header">impl <a class="struct" href="struct.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.parse" class="method has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#800-805">source</a><h4 class="code-header">pub fn <a href="#method.parse" class="fnname">parse</a>(<br> input: &str,<br> description: &impl <a class="trait" href="parsing/trait.Parsable.html" title="trait time::parsing::Parsable">Parsable</a> + ?Sized<br>) -> Result<Self, <a class="enum" href="error/enum.Parse.html" title="enum time::error::Parse">Parse</a>></h4></section></summary><div class="docblock"><p>Parse a <code>PrimitiveDateTime</code> from the input using the provided <a href="format_description/index.html">format |
| description</a>.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>format = <span class="macro">format_description!</span>(<span class="string">"[year]-[month]-[day] [hour]:[minute]:[second]"</span>); |
| <span class="macro">assert_eq!</span>( |
| PrimitiveDateTime::parse(<span class="string">"2020-01-02 03:04:05"</span>, <span class="kw-2">&</span>format)<span class="question-mark">?</span>, |
| <span class="macro">datetime!</span>(<span class="number">2020</span>-<span class="number">01</span>-<span class="number">02 03</span>:<span class="number">04</span>:<span class="number">05</span>) |
| );</code></pre><a class="test-arrow" target="_blank" href="https://play.rust-lang.org?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23time%3B%0Afn%20main()%20%7B%20fn%20_inner()%20-%3E%20Result%3C()%2C%20impl%20core%3A%3Afmt%3A%3ADebug%3E%20%7B%0Ause%20time%3A%3APrimitiveDateTime%3B%0Ause%20time_macros%3A%3A%7Bdatetime%2C%20format_description%7D%3B%0Alet%20format%20%3D%20format_description!(%22%5Byear%5D-%5Bmonth%5D-%5Bday%5D%20%5Bhour%5D%3A%5Bminute%5D%3A%5Bsecond%5D%22)%3B%0Aassert_eq!(%0A%20%20%20%20PrimitiveDateTime%3A%3Aparse(%222020-01-02%2003%3A04%3A05%22%2C%20%26format)%3F%2C%0A%20%20%20%20datetime!(2020-01-02%2003%3A04%3A05)%0A)%3B%0AOk%3A%3A%3C_%2C%20time%3A%3AError%3E(())%0A%7D%20_inner().unwrap()%20%7D&edition=2021">Run</a></div> |
| </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-PrimitiveDateTime" class="impl has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#822-828">source</a><a href="#impl-Add%3CDuration%3E-for-PrimitiveDateTime" class="anchor"></a><h3 class="code-header">impl Add<<a class="struct" href="struct.Duration.html" title="struct time::Duration">Duration</a>> for <a class="struct" href="struct.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</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.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</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/time/primitive_date_time.rs.html#825-827">source</a><a href="#method.add" class="anchor"></a><h4 class="code-header">fn <a class="fnname">add</a>(self, duration: <a class="struct" href="struct.Duration.html" title="struct time::Duration">Duration</a>) -> Self::Output</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-PrimitiveDateTime-1" class="impl has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#830-836">source</a><a href="#impl-Add%3CDuration%3E-for-PrimitiveDateTime-1" class="anchor"></a><h3 class="code-header">impl Add<Duration> for <a class="struct" href="struct.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</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.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</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-1" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#833-835">source</a><a href="#method.add-1" class="anchor"></a><h4 class="code-header">fn <a class="fnname">add</a>(self, duration: StdDuration) -> Self::Output</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-PrimitiveDateTime" class="impl has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#838-842">source</a><a href="#impl-AddAssign%3CDuration%3E-for-PrimitiveDateTime" class="anchor"></a><h3 class="code-header">impl AddAssign<<a class="struct" href="struct.Duration.html" title="struct time::Duration">Duration</a>> for <a class="struct" href="struct.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</a></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/time/primitive_date_time.rs.html#839-841">source</a><a href="#method.add_assign" class="anchor"></a><h4 class="code-header">fn <a class="fnname">add_assign</a>(&mut self, duration: <a class="struct" href="struct.Duration.html" title="struct time::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-AddAssign%3CDuration%3E-for-PrimitiveDateTime-1" class="impl has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#844-848">source</a><a href="#impl-AddAssign%3CDuration%3E-for-PrimitiveDateTime-1" class="anchor"></a><h3 class="code-header">impl AddAssign<Duration> for <a class="struct" href="struct.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</a></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/time/primitive_date_time.rs.html#845-847">source</a><a href="#method.add_assign-1" class="anchor"></a><h4 class="code-header">fn <a class="fnname">add_assign</a>(&mut self, duration: StdDuration)</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-PrimitiveDateTime" class="impl has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#20">source</a><a href="#impl-Clone-for-PrimitiveDateTime" class="anchor"></a><h3 class="code-header">impl Clone for <a class="struct" href="struct.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</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/time/primitive_date_time.rs.html#20">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.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</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-PrimitiveDateTime" class="impl has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#814-818">source</a><a href="#impl-Debug-for-PrimitiveDateTime" class="anchor"></a><h3 class="code-header">impl Debug for <a class="struct" href="struct.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</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/time/primitive_date_time.rs.html#815-817">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'>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-Deserialize%3C%27a%3E-for-PrimitiveDateTime" class="impl has-srclink"><a class="srclink rightside" href="../src/time/serde/mod.rs.html#353-361">source</a><a href="#impl-Deserialize%3C%27a%3E-for-PrimitiveDateTime" class="anchor"></a><h3 class="code-header">impl<'a> <a class="trait" href="../serde/de/trait.Deserialize.html" title="trait serde::de::Deserialize">Deserialize</a><'a> for <a class="struct" href="struct.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.deserialize" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/time/serde/mod.rs.html#354-360">source</a><a href="#method.deserialize" class="anchor"></a><h4 class="code-header">fn <a href="../serde/de/trait.Deserialize.html#tymethod.deserialize" class="fnname">deserialize</a><D: <a class="trait" href="../serde/de/trait.Deserializer.html" title="trait serde::de::Deserializer">Deserializer</a><'a>>(deserializer: D) -> Result<Self, D::<a class="associatedtype" href="../serde/de/trait.Deserializer.html#associatedtype.Error" title="type serde::de::Deserializer::Error">Error</a>></h4></section></summary><div class='docblock'>Deserialize this value from the given Serde deserializer. <a href="../serde/de/trait.Deserialize.html#tymethod.deserialize">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Display-for-PrimitiveDateTime" class="impl has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#808-812">source</a><a href="#impl-Display-for-PrimitiveDateTime" class="anchor"></a><h3 class="code-header">impl Display for <a class="struct" href="struct.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</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/time/primitive_date_time.rs.html#809-811">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-Hash-for-PrimitiveDateTime" class="impl has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#20">source</a><a href="#impl-Hash-for-PrimitiveDateTime" class="anchor"></a><h3 class="code-header">impl Hash for <a class="struct" href="struct.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</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/time/primitive_date_time.rs.html#20">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-Ord-for-PrimitiveDateTime" class="impl has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#20">source</a><a href="#impl-Ord-for-PrimitiveDateTime" class="anchor"></a><h3 class="code-header">impl Ord for <a class="struct" href="struct.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</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/time/primitive_date_time.rs.html#20">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.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</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%3CPrimitiveDateTime%3E-for-PrimitiveDateTime" class="impl has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#20">source</a><a href="#impl-PartialEq%3CPrimitiveDateTime%3E-for-PrimitiveDateTime" class="anchor"></a><h3 class="code-header">impl PartialEq<<a class="struct" href="struct.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</a>> for <a class="struct" href="struct.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</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/time/primitive_date_time.rs.html#20">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.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</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%3CPrimitiveDateTime%3E-for-PrimitiveDateTime" class="impl has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#20">source</a><a href="#impl-PartialOrd%3CPrimitiveDateTime%3E-for-PrimitiveDateTime" class="anchor"></a><h3 class="code-header">impl PartialOrd<<a class="struct" href="struct.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</a>> for <a class="struct" href="struct.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</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/time/primitive_date_time.rs.html#20">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.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</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-Serialize-for-PrimitiveDateTime" class="impl has-srclink"><a class="srclink rightside" href="../src/time/serde/mod.rs.html#331-351">source</a><a href="#impl-Serialize-for-PrimitiveDateTime" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="../serde/ser/trait.Serialize.html" title="trait serde::ser::Serialize">Serialize</a> for <a class="struct" href="struct.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.serialize" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/time/serde/mod.rs.html#332-350">source</a><a href="#method.serialize" class="anchor"></a><h4 class="code-header">fn <a href="../serde/ser/trait.Serialize.html#tymethod.serialize" class="fnname">serialize</a><S: <a class="trait" href="../serde/ser/trait.Serializer.html" title="trait serde::ser::Serializer">Serializer</a>>(&self, serializer: S) -> Result<S::<a class="associatedtype" href="../serde/ser/trait.Serializer.html#associatedtype.Ok" title="type serde::ser::Serializer::Ok">Ok</a>, S::<a class="associatedtype" href="../serde/ser/trait.Serializer.html#associatedtype.Error" title="type serde::ser::Serializer::Error">Error</a>></h4></section></summary><div class='docblock'>Serialize this value into the given Serde serializer. <a href="../serde/ser/trait.Serialize.html#tymethod.serialize">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Sub%3CDuration%3E-for-PrimitiveDateTime" class="impl has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#850-856">source</a><a href="#impl-Sub%3CDuration%3E-for-PrimitiveDateTime" class="anchor"></a><h3 class="code-header">impl Sub<<a class="struct" href="struct.Duration.html" title="struct time::Duration">Duration</a>> for <a class="struct" href="struct.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</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.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</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/time/primitive_date_time.rs.html#853-855">source</a><a href="#method.sub" class="anchor"></a><h4 class="code-header">fn <a class="fnname">sub</a>(self, duration: <a class="struct" href="struct.Duration.html" title="struct time::Duration">Duration</a>) -> Self::Output</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-PrimitiveDateTime-1" class="impl has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#858-864">source</a><a href="#impl-Sub%3CDuration%3E-for-PrimitiveDateTime-1" class="anchor"></a><h3 class="code-header">impl Sub<Duration> for <a class="struct" href="struct.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</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.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</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-1" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#861-863">source</a><a href="#method.sub-1" class="anchor"></a><h4 class="code-header">fn <a class="fnname">sub</a>(self, duration: StdDuration) -> Self::Output</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%3CPrimitiveDateTime%3E-for-PrimitiveDateTime" class="impl has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#878-884">source</a><a href="#impl-Sub%3CPrimitiveDateTime%3E-for-PrimitiveDateTime" class="anchor"></a><h3 class="code-header">impl Sub<<a class="struct" href="struct.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</a>> for <a class="struct" href="struct.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</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 time::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-2" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#881-883">source</a><a href="#method.sub-2" class="anchor"></a><h4 class="code-header">fn <a class="fnname">sub</a>(self, rhs: Self) -> Self::Output</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-PrimitiveDateTime" class="impl has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#866-870">source</a><a href="#impl-SubAssign%3CDuration%3E-for-PrimitiveDateTime" class="anchor"></a><h3 class="code-header">impl SubAssign<<a class="struct" href="struct.Duration.html" title="struct time::Duration">Duration</a>> for <a class="struct" href="struct.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</a></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/time/primitive_date_time.rs.html#867-869">source</a><a href="#method.sub_assign" class="anchor"></a><h4 class="code-header">fn <a class="fnname">sub_assign</a>(&mut self, duration: <a class="struct" href="struct.Duration.html" title="struct time::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-SubAssign%3CDuration%3E-for-PrimitiveDateTime-1" class="impl has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#872-876">source</a><a href="#impl-SubAssign%3CDuration%3E-for-PrimitiveDateTime-1" class="anchor"></a><h3 class="code-header">impl SubAssign<Duration> for <a class="struct" href="struct.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</a></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/time/primitive_date_time.rs.html#873-875">source</a><a href="#method.sub_assign-1" class="anchor"></a><h4 class="code-header">fn <a class="fnname">sub_assign</a>(&mut self, duration: StdDuration)</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-TryFrom%3CParsed%3E-for-PrimitiveDateTime" class="impl has-srclink"><a class="srclink rightside" href="../src/time/parsing/parsed.rs.html#774-780">source</a><a href="#impl-TryFrom%3CParsed%3E-for-PrimitiveDateTime" class="anchor"></a><h3 class="code-header">impl TryFrom<<a class="struct" href="parsing/struct.Parsed.html" title="struct time::parsing::Parsed">Parsed</a>> for <a class="struct" href="struct.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</a></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> = <DateTime<None> as TryFrom<<a class="struct" href="parsing/struct.Parsed.html" title="struct time::parsing::Parsed">Parsed</a>>>::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_from" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/time/parsing/parsed.rs.html#777-779">source</a><a href="#method.try_from" class="anchor"></a><h4 class="code-header">fn <a class="fnname">try_from</a>(parsed: <a class="struct" href="parsing/struct.Parsed.html" title="struct time::parsing::Parsed">Parsed</a>) -> Result<Self, Self::Error></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><section id="impl-Copy-for-PrimitiveDateTime" class="impl has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#20">source</a><a href="#impl-Copy-for-PrimitiveDateTime" class="anchor"></a><h3 class="code-header">impl Copy for <a class="struct" href="struct.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</a></h3></section><section id="impl-Eq-for-PrimitiveDateTime" class="impl has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#20">source</a><a href="#impl-Eq-for-PrimitiveDateTime" class="anchor"></a><h3 class="code-header">impl Eq for <a class="struct" href="struct.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</a></h3></section><section id="impl-StructuralEq-for-PrimitiveDateTime" class="impl has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#20">source</a><a href="#impl-StructuralEq-for-PrimitiveDateTime" class="anchor"></a><h3 class="code-header">impl StructuralEq for <a class="struct" href="struct.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</a></h3></section><section id="impl-StructuralPartialEq-for-PrimitiveDateTime" class="impl has-srclink"><a class="srclink rightside" href="../src/time/primitive_date_time.rs.html#20">source</a><a href="#impl-StructuralPartialEq-for-PrimitiveDateTime" class="anchor"></a><h3 class="code-header">impl StructuralPartialEq for <a class="struct" href="struct.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</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-PrimitiveDateTime" class="impl has-srclink"><a href="#impl-RefUnwindSafe-for-PrimitiveDateTime" class="anchor"></a><h3 class="code-header">impl RefUnwindSafe for <a class="struct" href="struct.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</a></h3></section><section id="impl-Send-for-PrimitiveDateTime" class="impl has-srclink"><a href="#impl-Send-for-PrimitiveDateTime" class="anchor"></a><h3 class="code-header">impl Send for <a class="struct" href="struct.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</a></h3></section><section id="impl-Sync-for-PrimitiveDateTime" class="impl has-srclink"><a href="#impl-Sync-for-PrimitiveDateTime" class="anchor"></a><h3 class="code-header">impl Sync for <a class="struct" href="struct.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</a></h3></section><section id="impl-Unpin-for-PrimitiveDateTime" class="impl has-srclink"><a href="#impl-Unpin-for-PrimitiveDateTime" class="anchor"></a><h3 class="code-header">impl Unpin for <a class="struct" href="struct.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</a></h3></section><section id="impl-UnwindSafe-for-PrimitiveDateTime" class="impl has-srclink"><a href="#impl-UnwindSafe-for-PrimitiveDateTime" class="anchor"></a><h3 class="code-header">impl UnwindSafe for <a class="struct" href="struct.PrimitiveDateTime.html" title="struct time::PrimitiveDateTime">PrimitiveDateTime</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-PrimitiveDateTime" class="impl has-srclink"><a href="#impl-Any-for-PrimitiveDateTime" 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-PrimitiveDateTime" class="impl has-srclink"><a href="#impl-Borrow%3CT%3E-for-PrimitiveDateTime" 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-PrimitiveDateTime" class="impl has-srclink"><a href="#impl-BorrowMut%3CT%3E-for-PrimitiveDateTime" 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-PrimitiveDateTime" class="impl has-srclink"><a href="#impl-From%3CT%3E-for-PrimitiveDateTime" 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-PrimitiveDateTime" class="impl has-srclink"><a href="#impl-Into%3CU%3E-for-PrimitiveDateTime" 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-PrimitiveDateTime" class="impl has-srclink"><a href="#impl-ToOwned-for-PrimitiveDateTime" 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-PrimitiveDateTime" class="impl has-srclink"><a href="#impl-ToString-for-PrimitiveDateTime" 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-PrimitiveDateTime" class="impl has-srclink"><a href="#impl-TryFrom%3CU%3E-for-PrimitiveDateTime" 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-2" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error-2" 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-1" 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-1" 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-PrimitiveDateTime" class="impl has-srclink"><a href="#impl-TryInto%3CU%3E-for-PrimitiveDateTime" 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-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> = <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><section id="impl-DeserializeOwned-for-PrimitiveDateTime" class="impl has-srclink"><a class="srclink rightside" href="../src/serde/de/mod.rs.html#604">source</a><a href="#impl-DeserializeOwned-for-PrimitiveDateTime" class="anchor"></a><h3 class="code-header">impl<T> <a class="trait" href="../serde/de/trait.DeserializeOwned.html" title="trait serde::de::DeserializeOwned">DeserializeOwned</a> for T<span class="where fmt-newline">where<br> T: for<'de> <a class="trait" href="../serde/de/trait.Deserialize.html" title="trait serde::de::Deserialize">Deserialize</a><'de>,</span></h3></section></div></section></div></main><div id="rustdoc-vars" data-root-path="../" data-current-crate="time" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.66.0-nightly (5c8bff74b 2022-10-21)" ></div></body></html> |