| <!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="ISO 8601 combined date and time with time zone."><meta name="keywords" content="rust, rustlang, rust-lang, DateTime"><title>DateTime in chrono - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" href="../normalize.css"><link rel="stylesheet" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" href="../ayu.css" disabled><link rel="stylesheet" href="../dark.css" disabled><link rel="stylesheet" href="../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../storage.js"></script><script defer src="sidebar-items.js"></script><script defer src="../main.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../favicon.svg"></head><body class="rustdoc struct"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button><a class="sidebar-logo" href="../chrono/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><h2></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../chrono/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">DateTime</a></h2><div class="sidebar-elems"><section><h3><a href="#implementations">Associated Constants</a></h3><ul class="block"><li><a href="#associatedconstant.MAX_UTC">MAX_UTC</a></li><li><a href="#associatedconstant.MIN_UTC">MIN_UTC</a></li></ul><h3><a href="#implementations">Methods</a></h3><ul class="block"><li><a href="#method.checked_add_days">checked_add_days</a></li><li><a href="#method.checked_add_months">checked_add_months</a></li><li><a href="#method.checked_add_signed">checked_add_signed</a></li><li><a href="#method.checked_sub_days">checked_sub_days</a></li><li><a href="#method.checked_sub_months">checked_sub_months</a></li><li><a href="#method.checked_sub_signed">checked_sub_signed</a></li><li><a href="#method.date">date</a></li><li><a href="#method.date_naive">date_naive</a></li><li><a href="#method.fixed_offset">fixed_offset</a></li><li><a href="#method.format">format</a></li><li><a href="#method.format_with_items">format_with_items</a></li><li><a href="#method.from_local">from_local</a></li><li><a href="#method.from_utc">from_utc</a></li><li><a href="#method.naive_local">naive_local</a></li><li><a href="#method.naive_utc">naive_utc</a></li><li><a href="#method.offset">offset</a></li><li><a href="#method.parse_and_remainder">parse_and_remainder</a></li><li><a href="#method.parse_from_rfc2822">parse_from_rfc2822</a></li><li><a href="#method.parse_from_rfc3339">parse_from_rfc3339</a></li><li><a href="#method.parse_from_str">parse_from_str</a></li><li><a href="#method.signed_duration_since">signed_duration_since</a></li><li><a href="#method.time">time</a></li><li><a href="#method.timestamp">timestamp</a></li><li><a href="#method.timestamp_micros">timestamp_micros</a></li><li><a href="#method.timestamp_millis">timestamp_millis</a></li><li><a href="#method.timestamp_nanos">timestamp_nanos</a></li><li><a href="#method.timestamp_subsec_micros">timestamp_subsec_micros</a></li><li><a href="#method.timestamp_subsec_millis">timestamp_subsec_millis</a></li><li><a href="#method.timestamp_subsec_nanos">timestamp_subsec_nanos</a></li><li><a href="#method.timezone">timezone</a></li><li><a href="#method.to_rfc2822">to_rfc2822</a></li><li><a href="#method.to_rfc3339">to_rfc3339</a></li><li><a href="#method.to_rfc3339_opts">to_rfc3339_opts</a></li><li><a href="#method.with_timezone">with_timezone</a></li><li><a href="#method.years_since">years_since</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block"><li><a href="#impl-Add%3CDays%3E-for-DateTime%3CTz%3E">Add<Days></a></li><li><a href="#impl-Add%3CDuration%3E-for-DateTime%3CTz%3E">Add<Duration></a></li><li><a href="#impl-Add%3CFixedOffset%3E-for-DateTime%3CTz%3E">Add<FixedOffset></a></li><li><a href="#impl-Add%3CMonths%3E-for-DateTime%3CTz%3E">Add<Months></a></li><li><a href="#impl-AddAssign%3CDuration%3E-for-DateTime%3CTz%3E">AddAssign<Duration></a></li><li><a href="#impl-Clone-for-DateTime%3CTz%3E">Clone</a></li><li><a href="#impl-Copy-for-DateTime%3CTz%3E">Copy</a></li><li><a href="#impl-Datelike-for-DateTime%3CTz%3E">Datelike</a></li><li><a href="#impl-Debug-for-DateTime%3CTz%3E">Debug</a></li><li><a href="#impl-Default-for-DateTime%3CFixedOffset%3E">Default</a></li><li><a href="#impl-Default-for-DateTime%3CUtc%3E">Default</a></li><li><a href="#impl-Display-for-DateTime%3CTz%3E">Display</a></li><li><a href="#impl-DurationRound-for-DateTime%3CTz%3E">DurationRound</a></li><li><a href="#impl-Eq-for-DateTime%3CTz%3E">Eq</a></li><li><a href="#impl-From%3CDateTime%3CFixedOffset%3E%3E-for-DateTime%3CUtc%3E">From<DateTime<FixedOffset>></a></li><li><a href="#impl-From%3CDateTime%3CTz%3E%3E-for-SystemTime">From<DateTime<Tz>></a></li><li><a href="#impl-From%3CDateTime%3CUtc%3E%3E-for-DateTime%3CFixedOffset%3E">From<DateTime<Utc>></a></li><li><a href="#impl-From%3CSystemTime%3E-for-DateTime%3CUtc%3E">From<SystemTime></a></li><li><a href="#impl-FromStr-for-DateTime%3CFixedOffset%3E">FromStr</a></li><li><a href="#impl-FromStr-for-DateTime%3CUtc%3E">FromStr</a></li><li><a href="#impl-Hash-for-DateTime%3CTz%3E">Hash</a></li><li><a href="#impl-Ord-for-DateTime%3CTz%3E">Ord</a></li><li><a href="#impl-PartialEq%3CDateTime%3CTz2%3E%3E-for-DateTime%3CTz%3E">PartialEq<DateTime<Tz2>></a></li><li><a href="#impl-PartialOrd%3CDateTime%3CTz2%3E%3E-for-DateTime%3CTz%3E">PartialOrd<DateTime<Tz2>></a></li><li><a href="#impl-Send-for-DateTime%3CTz%3E">Send</a></li><li><a href="#impl-Sub%3CDateTime%3CTz%3E%3E-for-DateTime%3CTz%3E">Sub<DateTime<Tz>></a></li><li><a href="#impl-Sub%3CDays%3E-for-DateTime%3CTz%3E">Sub<Days></a></li><li><a href="#impl-Sub%3CDuration%3E-for-DateTime%3CTz%3E">Sub<Duration></a></li><li><a href="#impl-Sub%3CFixedOffset%3E-for-DateTime%3CTz%3E">Sub<FixedOffset></a></li><li><a href="#impl-Sub%3CMonths%3E-for-DateTime%3CTz%3E">Sub<Months></a></li><li><a href="#impl-SubAssign%3CDuration%3E-for-DateTime%3CTz%3E">SubAssign<Duration></a></li><li><a href="#impl-Timelike-for-DateTime%3CTz%3E">Timelike</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block"><li><a href="#impl-RefUnwindSafe-for-DateTime%3CTz%3E">RefUnwindSafe</a></li><li><a href="#impl-Sync-for-DateTime%3CTz%3E">Sync</a></li><li><a href="#impl-Unpin-for-DateTime%3CTz%3E">Unpin</a></li><li><a href="#impl-UnwindSafe-for-DateTime%3CTz%3E">UnwindSafe</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block"><li><a href="#impl-Any-for-DateTime%3CTz%3E">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-DateTime%3CTz%3E">Borrow<T></a></li><li><a href="#impl-BorrowMut%3CT%3E-for-DateTime%3CTz%3E">BorrowMut<T></a></li><li><a href="#impl-From%3CT%3E-for-DateTime%3CTz%3E">From<T></a></li><li><a href="#impl-Into%3CU%3E-for-DateTime%3CTz%3E">Into<U></a></li><li><a href="#impl-ToOwned-for-DateTime%3CTz%3E">ToOwned</a></li><li><a href="#impl-ToString-for-DateTime%3CTz%3E">ToString</a></li><li><a href="#impl-TryFrom%3CU%3E-for-DateTime%3CTz%3E">TryFrom<U></a></li><li><a href="#impl-TryInto%3CU%3E-for-DateTime%3CTz%3E">TryInto<U></a></li></ul></section><h2><a href="index.html">In chrono</a></h2></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../wheel.svg"></a></div></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn">Struct <a href="index.html">chrono</a>::<wbr><a class="struct" href="#">DateTime</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../clipboard.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="srclink" href="../src/chrono/datetime/mod.rs.html#89-92">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 DateTime<Tz: <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>> { /* private fields */ }</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>ISO 8601 combined date and time with time zone.</p> |
| <p>There are some constructors implemented here (the <code>from_*</code> methods), but |
| the general-purpose constructors are all via the methods on the |
| <a href="./offset/trait.TimeZone.html"><code>TimeZone</code></a> implementations.</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-DateTime%3CTz%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#101-452">source</a><a href="#impl-DateTime%3CTz%3E" class="anchor"></a><h3 class="code-header">impl<Tz: <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>> <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from_utc" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#117-119">source</a><h4 class="code-header">pub fn <a href="#method.from_utc" class="fnname">from_utc</a>(datetime: <a class="struct" href="naive/struct.NaiveDateTime.html" title="struct chrono::naive::NaiveDateTime">NaiveDateTime</a>, offset: Tz::<a class="associatedtype" href="offset/trait.TimeZone.html#associatedtype.Offset" title="type chrono::offset::TimeZone::Offset">Offset</a>) -> <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h4></section></summary><div class="docblock"><p>Makes a new <code>DateTime</code> with given <em>UTC</em> datetime and offset. |
| The local datetime should be constructed via the <code>TimeZone</code> trait.</p> |
| <h5 id="example"><a href="#example">Example</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{DateTime, TimeZone, NaiveDateTime, Utc}; |
| |
| <span class="kw">let </span>dt = DateTime::<Utc>::from_utc(NaiveDateTime::from_timestamp_opt(<span class="number">61</span>, <span class="number">0</span>).unwrap(), Utc); |
| <span class="macro">assert_eq!</span>(Utc.timestamp_opt(<span class="number">61</span>, <span class="number">0</span>).unwrap(), dt);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from_local" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#147-151">source</a><h4 class="code-header">pub fn <a href="#method.from_local" class="fnname">from_local</a>(datetime: <a class="struct" href="naive/struct.NaiveDateTime.html" title="struct chrono::naive::NaiveDateTime">NaiveDateTime</a>, offset: Tz::<a class="associatedtype" href="offset/trait.TimeZone.html#associatedtype.Offset" title="type chrono::offset::TimeZone::Offset">Offset</a>) -> <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h4></section></summary><div class="docblock"><p>Makes a new <code>DateTime</code> with given <strong>local</strong> datetime and offset that |
| presents local timezone.</p> |
| <h5 id="example-1"><a href="#example-1">Example</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::DateTime; |
| <span class="kw">use </span>chrono::naive::NaiveDate; |
| <span class="kw">use </span>chrono::offset::{Utc, FixedOffset}; |
| |
| <span class="kw">let </span>naivedatetime_utc = NaiveDate::from_ymd_opt(<span class="number">2000</span>, <span class="number">1</span>, <span class="number">12</span>).unwrap().and_hms_opt(<span class="number">2</span>, <span class="number">0</span>, <span class="number">0</span>).unwrap(); |
| <span class="kw">let </span>datetime_utc = DateTime::<Utc>::from_utc(naivedatetime_utc, Utc); |
| |
| <span class="kw">let </span>timezone_east = FixedOffset::east_opt(<span class="number">8 </span>* <span class="number">60 </span>* <span class="number">60</span>).unwrap(); |
| <span class="kw">let </span>naivedatetime_east = NaiveDate::from_ymd_opt(<span class="number">2000</span>, <span class="number">1</span>, <span class="number">12</span>).unwrap().and_hms_opt(<span class="number">10</span>, <span class="number">0</span>, <span class="number">0</span>).unwrap(); |
| <span class="kw">let </span>datetime_east = DateTime::<FixedOffset>::from_local(naivedatetime_east, timezone_east); |
| |
| <span class="kw">let </span>timezone_west = FixedOffset::west_opt(<span class="number">7 </span>* <span class="number">60 </span>* <span class="number">60</span>).unwrap(); |
| <span class="kw">let </span>naivedatetime_west = NaiveDate::from_ymd_opt(<span class="number">2000</span>, <span class="number">1</span>, <span class="number">11</span>).unwrap().and_hms_opt(<span class="number">19</span>, <span class="number">0</span>, <span class="number">0</span>).unwrap(); |
| <span class="kw">let </span>datetime_west = DateTime::<FixedOffset>::from_local(naivedatetime_west, timezone_west); |
| <span class="macro">assert_eq!</span>(datetime_east, datetime_utc.with_timezone(<span class="kw-2">&</span>timezone_east)); |
| <span class="macro">assert_eq!</span>(datetime_west, datetime_utc.with_timezone(<span class="kw-2">&</span>timezone_west));</code></pre></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/chrono/datetime/mod.rs.html#162-164">source</a><h4 class="code-header">pub fn <a href="#method.date" class="fnname">date</a>(&self) -> <a class="struct" href="struct.Date.html" title="struct chrono::Date">Date</a><Tz></h4></section><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated since 0.4.23: Use <code>date_naive()</code> instead</span></div></span></summary><div class="docblock"><p>Retrieves a date component</p> |
| <p>Unless you are immediately planning on turning this into a <code>DateTime</code> |
| with the same Timezone you should use the |
| <a href="struct.DateTime.html#method.date_naive"><code>date_naive</code></a> method.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.date_naive" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#180-183">source</a><h4 class="code-header">pub fn <a href="#method.date_naive" class="fnname">date_naive</a>(&self) -> <a class="struct" href="naive/struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h4></section></summary><div class="docblock"><p>Retrieves the Date without an associated timezone</p> |
| <p><a href="naive/struct.NaiveDate.html" title="NaiveDate"><code>NaiveDate</code></a> is a more well-defined type, and has more traits implemented on it, |
| so should be preferred to <a href="struct.Date.html" title="Date"><code>Date</code></a> any time you truly want to operate on Dates.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::prelude::<span class="kw-2">*</span>; |
| |
| <span class="kw">let </span>date: DateTime<Utc> = Utc.with_ymd_and_hms(<span class="number">2020</span>, <span class="number">1</span>, <span class="number">1</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>).unwrap(); |
| <span class="kw">let </span>other: DateTime<FixedOffset> = FixedOffset::east_opt(<span class="number">23</span>).unwrap().with_ymd_and_hms(<span class="number">2020</span>, <span class="number">1</span>, <span class="number">1</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>).unwrap(); |
| <span class="macro">assert_eq!</span>(date.date_naive(), other.date_naive());</code></pre></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/chrono/datetime/mod.rs.html#189-191">source</a><h4 class="code-header">pub fn <a href="#method.time" class="fnname">time</a>(&self) -> <a class="struct" href="naive/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a></h4></section></summary><div class="docblock"><p>Retrieves a time component. |
| Unlike <code>date</code>, this is not associated to the time zone.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.timestamp" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#197-199">source</a><h4 class="code-header">pub fn <a href="#method.timestamp" class="fnname">timestamp</a>(&self) -> i64</h4></section></summary><div class="docblock"><p>Returns the number of non-leap seconds since January 1, 1970 0:00:00 UTC |
| (aka “UNIX timestamp”).</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.timestamp_millis" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#221-223">source</a><h4 class="code-header">pub fn <a href="#method.timestamp_millis" class="fnname">timestamp_millis</a>(&self) -> i64</h4></section></summary><div class="docblock"><p>Returns the number of non-leap-milliseconds since January 1, 1970 UTC</p> |
| <p>Note that this does reduce the number of years that can be represented |
| from ~584 Billion to ~584 Million. (If this is a problem, please file |
| an issue to let me know what domain needs millisecond precision over |
| billions of years, I’m curious.)</p> |
| <h5 id="example-2"><a href="#example-2">Example</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{Utc, NaiveDate}; |
| |
| <span class="kw">let </span>dt = NaiveDate::from_ymd_opt(<span class="number">1970</span>, <span class="number">1</span>, <span class="number">1</span>).unwrap().and_hms_milli_opt(<span class="number">0</span>, <span class="number">0</span>, <span class="number">1</span>, <span class="number">444</span>).unwrap().and_local_timezone(Utc).unwrap(); |
| <span class="macro">assert_eq!</span>(dt.timestamp_millis(), <span class="number">1_444</span>); |
| |
| <span class="kw">let </span>dt = NaiveDate::from_ymd_opt(<span class="number">2001</span>, <span class="number">9</span>, <span class="number">9</span>).unwrap().and_hms_milli_opt(<span class="number">1</span>, <span class="number">46</span>, <span class="number">40</span>, <span class="number">555</span>).unwrap().and_local_timezone(Utc).unwrap(); |
| <span class="macro">assert_eq!</span>(dt.timestamp_millis(), <span class="number">1_000_000_000_555</span>);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.timestamp_micros" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#245-247">source</a><h4 class="code-header">pub fn <a href="#method.timestamp_micros" class="fnname">timestamp_micros</a>(&self) -> i64</h4></section></summary><div class="docblock"><p>Returns the number of non-leap-microseconds since January 1, 1970 UTC</p> |
| <p>Note that this does reduce the number of years that can be represented |
| from ~584 Billion to ~584 Thousand. (If this is a problem, please file |
| an issue to let me know what domain needs microsecond precision over |
| millennia, I’m curious.)</p> |
| <h5 id="example-3"><a href="#example-3">Example</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{Utc, NaiveDate}; |
| |
| <span class="kw">let </span>dt = NaiveDate::from_ymd_opt(<span class="number">1970</span>, <span class="number">1</span>, <span class="number">1</span>).unwrap().and_hms_micro_opt(<span class="number">0</span>, <span class="number">0</span>, <span class="number">1</span>, <span class="number">444</span>).unwrap().and_local_timezone(Utc).unwrap(); |
| <span class="macro">assert_eq!</span>(dt.timestamp_micros(), <span class="number">1_000_444</span>); |
| |
| <span class="kw">let </span>dt = NaiveDate::from_ymd_opt(<span class="number">2001</span>, <span class="number">9</span>, <span class="number">9</span>).unwrap().and_hms_micro_opt(<span class="number">1</span>, <span class="number">46</span>, <span class="number">40</span>, <span class="number">555</span>).unwrap().and_local_timezone(Utc).unwrap(); |
| <span class="macro">assert_eq!</span>(dt.timestamp_micros(), <span class="number">1_000_000_000_000_555</span>);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.timestamp_nanos" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#269-271">source</a><h4 class="code-header">pub fn <a href="#method.timestamp_nanos" class="fnname">timestamp_nanos</a>(&self) -> i64</h4></section></summary><div class="docblock"><p>Returns the number of non-leap-nanoseconds since January 1, 1970 UTC</p> |
| <p>Note that this does reduce the number of years that can be represented |
| from ~584 Billion to ~584. (If this is a problem, please file |
| an issue to let me know what domain needs nanosecond precision over |
| millennia, I’m curious.)</p> |
| <h5 id="example-4"><a href="#example-4">Example</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{Utc, NaiveDate}; |
| |
| <span class="kw">let </span>dt = NaiveDate::from_ymd_opt(<span class="number">1970</span>, <span class="number">1</span>, <span class="number">1</span>).unwrap().and_hms_nano_opt(<span class="number">0</span>, <span class="number">0</span>, <span class="number">1</span>, <span class="number">444</span>).unwrap().and_local_timezone(Utc).unwrap(); |
| <span class="macro">assert_eq!</span>(dt.timestamp_nanos(), <span class="number">1_000_000_444</span>); |
| |
| <span class="kw">let </span>dt = NaiveDate::from_ymd_opt(<span class="number">2001</span>, <span class="number">9</span>, <span class="number">9</span>).unwrap().and_hms_nano_opt(<span class="number">1</span>, <span class="number">46</span>, <span class="number">40</span>, <span class="number">555</span>).unwrap().and_local_timezone(Utc).unwrap(); |
| <span class="macro">assert_eq!</span>(dt.timestamp_nanos(), <span class="number">1_000_000_000_000_000_555</span>);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.timestamp_subsec_millis" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#280-282">source</a><h4 class="code-header">pub fn <a href="#method.timestamp_subsec_millis" class="fnname">timestamp_subsec_millis</a>(&self) -> u32</h4></section></summary><div class="docblock"><p>Returns the number of milliseconds since the last second boundary</p> |
| <p>warning: in event of a leap second, this may exceed 999</p> |
| <p>note: this is not the number of milliseconds since January 1, 1970 0:00:00 UTC</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.timestamp_subsec_micros" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#291-293">source</a><h4 class="code-header">pub fn <a href="#method.timestamp_subsec_micros" class="fnname">timestamp_subsec_micros</a>(&self) -> u32</h4></section></summary><div class="docblock"><p>Returns the number of microseconds since the last second boundary</p> |
| <p>warning: in event of a leap second, this may exceed 999_999</p> |
| <p>note: this is not the number of microseconds since January 1, 1970 0:00:00 UTC</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.timestamp_subsec_nanos" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#302-304">source</a><h4 class="code-header">pub fn <a href="#method.timestamp_subsec_nanos" class="fnname">timestamp_subsec_nanos</a>(&self) -> u32</h4></section></summary><div class="docblock"><p>Returns the number of nanoseconds since the last second boundary</p> |
| <p>warning: in event of a leap second, this may exceed 999_999_999</p> |
| <p>note: this is not the number of nanoseconds since January 1, 1970 0:00:00 UTC</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.offset" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#309-311">source</a><h4 class="code-header">pub fn <a href="#method.offset" class="fnname">offset</a>(&self) -> &Tz::<a class="associatedtype" href="offset/trait.TimeZone.html#associatedtype.Offset" title="type chrono::offset::TimeZone::Offset">Offset</a></h4></section></summary><div class="docblock"><p>Retrieves an associated offset from UTC.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.timezone" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#316-318">source</a><h4 class="code-header">pub fn <a href="#method.timezone" class="fnname">timezone</a>(&self) -> Tz</h4></section></summary><div class="docblock"><p>Retrieves an associated time zone.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.with_timezone" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#324-326">source</a><h4 class="code-header">pub fn <a href="#method.with_timezone" class="fnname">with_timezone</a><Tz2: <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>>(&self, tz: &Tz2) -> <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz2></h4></section></summary><div class="docblock"><p>Changes the associated time zone. |
| The returned <code>DateTime</code> references the same instant of time from the perspective of the provided time zone.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.fixed_offset" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#332-334">source</a><h4 class="code-header">pub fn <a href="#method.fixed_offset" class="fnname">fixed_offset</a>(&self) -> <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><<a class="struct" href="offset/struct.FixedOffset.html" title="struct chrono::offset::FixedOffset">FixedOffset</a>></h4></section></summary><div class="docblock"><p>Fix the offset from UTC to its current value, dropping the associated timezone information. |
| This it useful for converting a generic <code>DateTime<Tz: Timezone></code> to <code>DateTime<FixedOffset></code>.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.checked_add_signed" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#341-345">source</a><h4 class="code-header">pub fn <a href="#method.checked_add_signed" class="fnname">checked_add_signed</a>(self, rhs: <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">OldDuration</a>) -> Option<<a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz>></h4></section></summary><div class="docblock"><p>Adds given <code>Duration</code> to the current date and time.</p> |
| <p>Returns <code>None</code> when it will result in overflow.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.checked_add_months" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#354-359">source</a><h4 class="code-header">pub fn <a href="#method.checked_add_months" class="fnname">checked_add_months</a>(self, rhs: <a class="struct" href="struct.Months.html" title="struct chrono::Months">Months</a>) -> Option<<a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz>></h4></section></summary><div class="docblock"><p>Adds given <code>Months</code> to the current date and time.</p> |
| <p>Returns <code>None</code> when it will result in overflow, or if the |
| local time is not valid on the newly calculated date.</p> |
| <p>See <a href="naive/struct.NaiveDate.html#method.checked_add_months" title="NaiveDate::checked_add_months"><code>NaiveDate::checked_add_months</code></a> for more details on behavior</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.checked_sub_signed" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#366-370">source</a><h4 class="code-header">pub fn <a href="#method.checked_sub_signed" class="fnname">checked_sub_signed</a>(self, rhs: <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">OldDuration</a>) -> Option<<a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz>></h4></section></summary><div class="docblock"><p>Subtracts given <code>Duration</code> from the current date and time.</p> |
| <p>Returns <code>None</code> when it will result in overflow.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.checked_sub_months" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#379-384">source</a><h4 class="code-header">pub fn <a href="#method.checked_sub_months" class="fnname">checked_sub_months</a>(self, rhs: <a class="struct" href="struct.Months.html" title="struct chrono::Months">Months</a>) -> Option<<a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz>></h4></section></summary><div class="docblock"><p>Subtracts given <code>Months</code> from the current date and time.</p> |
| <p>Returns <code>None</code> when it will result in overflow, or if the |
| local time is not valid on the newly calculated date.</p> |
| <p>See <a href="naive/struct.NaiveDate.html#method.checked_sub_months" title="NaiveDate::checked_sub_months"><code>NaiveDate::checked_sub_months</code></a> for more details on behavior</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.checked_add_days" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#390-395">source</a><h4 class="code-header">pub fn <a href="#method.checked_add_days" class="fnname">checked_add_days</a>(self, days: <a class="struct" href="naive/struct.Days.html" title="struct chrono::naive::Days">Days</a>) -> Option<Self></h4></section></summary><div class="docblock"><p>Add a duration in <a href="naive/struct.Days.html" title="Days"><code>Days</code></a> to the date part of the <code>DateTime</code></p> |
| <p>Returns <code>None</code> if the resulting date would be out of range.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.checked_sub_days" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#401-406">source</a><h4 class="code-header">pub fn <a href="#method.checked_sub_days" class="fnname">checked_sub_days</a>(self, days: <a class="struct" href="naive/struct.Days.html" title="struct chrono::naive::Days">Days</a>) -> Option<Self></h4></section></summary><div class="docblock"><p>Subtract a duration in <a href="naive/struct.Days.html" title="Days"><code>Days</code></a> from the date part of the <code>DateTime</code></p> |
| <p>Returns <code>None</code> if the resulting date would be out of range.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.signed_duration_since" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#412-414">source</a><h4 class="code-header">pub fn <a href="#method.signed_duration_since" class="fnname">signed_duration_since</a><Tz2: <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>>(<br> self,<br> rhs: <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz2><br>) -> <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">OldDuration</a></h4></section></summary><div class="docblock"><p>Subtracts another <code>DateTime</code> from the current date and time. |
| This does not overflow or underflow at all.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.naive_utc" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#419-421">source</a><h4 class="code-header">pub fn <a href="#method.naive_utc" class="fnname">naive_utc</a>(&self) -> <a class="struct" href="naive/struct.NaiveDateTime.html" title="struct chrono::naive::NaiveDateTime">NaiveDateTime</a></h4></section></summary><div class="docblock"><p>Returns a view to the naive UTC datetime.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.naive_local" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#426-428">source</a><h4 class="code-header">pub fn <a href="#method.naive_local" class="fnname">naive_local</a>(&self) -> <a class="struct" href="naive/struct.NaiveDateTime.html" title="struct chrono::naive::NaiveDateTime">NaiveDateTime</a></h4></section></summary><div class="docblock"><p>Returns a view to the naive local datetime.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.years_since" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#432-446">source</a><h4 class="code-header">pub fn <a href="#method.years_since" class="fnname">years_since</a>(&self, base: Self) -> Option<u32></h4></section></summary><div class="docblock"><p>Retrieve the elapsed years from now to the given <a href="struct.DateTime.html" title="DateTime"><code>DateTime</code></a>.</p> |
| </div></details><details class="rustdoc-toggle" open><summary><section id="associatedconstant.MIN_UTC" class="associatedconstant has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#449">source</a><h4 class="code-header">pub const <a href="#associatedconstant.MIN_UTC" class="constant">MIN_UTC</a>: <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><<a class="struct" href="offset/struct.Utc.html" title="struct chrono::offset::Utc">Utc</a>> = _</h4></section></summary><div class="docblock"><p>The minimum possible <code>DateTime<Utc></code>.</p> |
| </div></details><details class="rustdoc-toggle" open><summary><section id="associatedconstant.MAX_UTC" class="associatedconstant has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#451">source</a><h4 class="code-header">pub const <a href="#associatedconstant.MAX_UTC" class="constant">MAX_UTC</a>: <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><<a class="struct" href="offset/struct.Utc.html" title="struct chrono::offset::Utc">Utc</a>> = _</h4></section></summary><div class="docblock"><p>The maximum possible <code>DateTime<Utc></code>.</p> |
| </div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-DateTime%3CFixedOffset%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#554-655">source</a><a href="#impl-DateTime%3CFixedOffset%3E" class="anchor"></a><h3 class="code-header">impl <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><<a class="struct" href="offset/struct.FixedOffset.html" title="struct chrono::offset::FixedOffset">FixedOffset</a>></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.parse_from_rfc2822" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#570-575">source</a><h4 class="code-header">pub fn <a href="#method.parse_from_rfc2822" class="fnname">parse_from_rfc2822</a>(s: &str) -> <a class="type" href="format/type.ParseResult.html" title="type chrono::format::ParseResult">ParseResult</a><<a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><<a class="struct" href="offset/struct.FixedOffset.html" title="struct chrono::offset::FixedOffset">FixedOffset</a>>></h4></section></summary><div class="docblock"><p>Parses an RFC 2822 date-and-time string into a <code>DateTime<FixedOffset></code> value.</p> |
| <p>This parses valid RFC 2822 datetime strings (such as <code>Tue, 1 Jul 2003 10:52:37 +0200</code>) |
| and returns a new <a href="struct.DateTime.html" title="DateTime"><code>DateTime</code></a> instance with the parsed timezone as the <a href="offset/struct.FixedOffset.html" title="FixedOffset"><code>FixedOffset</code></a>.</p> |
| <p>RFC 2822 is the internet message standard that specifies the representation of times in HTTP |
| and email headers.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>( |
| DateTime::parse_from_rfc2822(<span class="string">"Wed, 18 Feb 2015 23:16:09 GMT"</span>).unwrap(), |
| FixedOffset::east_opt(<span class="number">0</span>).unwrap().with_ymd_and_hms(<span class="number">2015</span>, <span class="number">2</span>, <span class="number">18</span>, <span class="number">23</span>, <span class="number">16</span>, <span class="number">9</span>).unwrap() |
| );</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.parse_from_rfc3339" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#590-595">source</a><h4 class="code-header">pub fn <a href="#method.parse_from_rfc3339" class="fnname">parse_from_rfc3339</a>(s: &str) -> <a class="type" href="format/type.ParseResult.html" title="type chrono::format::ParseResult">ParseResult</a><<a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><<a class="struct" href="offset/struct.FixedOffset.html" title="struct chrono::offset::FixedOffset">FixedOffset</a>>></h4></section></summary><div class="docblock"><p>Parses an RFC 3339 date-and-time string into a <code>DateTime<FixedOffset></code> value.</p> |
| <p>Parses all valid RFC 3339 values (as well as the subset of valid ISO 8601 values that are |
| also valid RFC 3339 date-and-time values) and returns a new <a href="struct.DateTime.html" title="DateTime"><code>DateTime</code></a> with a |
| <a href="offset/struct.FixedOffset.html" title="FixedOffset"><code>FixedOffset</code></a> corresponding to the parsed timezone. While RFC 3339 values come in a wide |
| variety of shapes and sizes, <code>1996-12-19T16:39:57-08:00</code> is an example of the most commonly |
| encountered variety of RFC 3339 formats.</p> |
| <p>Why isn’t this named <code>parse_from_iso8601</code>? That’s because ISO 8601 allows representing |
| values in a wide range of formats, only some of which represent actual date-and-time |
| instances (rather than periods, ranges, dates, or times). Some valid ISO 8601 values are |
| also simultaneously valid RFC 3339 values, but not all RFC 3339 values are valid ISO 8601 |
| values (or the other way around).</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.parse_from_str" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#616-620">source</a><h4 class="code-header">pub fn <a href="#method.parse_from_str" class="fnname">parse_from_str</a>(s: &str, fmt: &str) -> <a class="type" href="format/type.ParseResult.html" title="type chrono::format::ParseResult">ParseResult</a><<a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><<a class="struct" href="offset/struct.FixedOffset.html" title="struct chrono::offset::FixedOffset">FixedOffset</a>>></h4></section></summary><div class="docblock"><p>Parses a string from a user-specified format into a <code>DateTime<FixedOffset></code> value.</p> |
| <p>Note that this method <em>requires a timezone</em> in the input string. See |
| <a href="./naive/struct.NaiveDateTime.html#method.parse_from_str"><code>NaiveDateTime::parse_from_str</code></a> |
| for a version that does not require a timezone in the to-be-parsed str. The returned |
| <a href="struct.DateTime.html" title="DateTime"><code>DateTime</code></a> value will have a <a href="offset/struct.FixedOffset.html" title="FixedOffset"><code>FixedOffset</code></a> reflecting the parsed timezone.</p> |
| <p>See the <a href="./format/strftime/index.html"><code>format::strftime</code> module</a> for supported format |
| sequences.</p> |
| <h5 id="example-5"><a href="#example-5">Example</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{DateTime, FixedOffset, TimeZone, NaiveDate}; |
| |
| <span class="kw">let </span>dt = DateTime::parse_from_str( |
| <span class="string">"1983 Apr 13 12:09:14.274 +0000"</span>, <span class="string">"%Y %b %d %H:%M:%S%.3f %z"</span>); |
| <span class="macro">assert_eq!</span>(dt, <span class="prelude-val">Ok</span>(FixedOffset::east_opt(<span class="number">0</span>).unwrap().from_local_datetime(<span class="kw-2">&</span>NaiveDate::from_ymd_opt(<span class="number">1983</span>, <span class="number">4</span>, <span class="number">13</span>).unwrap().and_hms_milli_opt(<span class="number">12</span>, <span class="number">9</span>, <span class="number">14</span>, <span class="number">274</span>).unwrap()).unwrap()));</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.parse_and_remainder" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#647-654">source</a><h4 class="code-header">pub fn <a href="#method.parse_and_remainder" class="fnname">parse_and_remainder</a><'a>(<br> s: &'a str,<br> fmt: &str<br>) -> <a class="type" href="format/type.ParseResult.html" title="type chrono::format::ParseResult">ParseResult</a><(<a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><<a class="struct" href="offset/struct.FixedOffset.html" title="struct chrono::offset::FixedOffset">FixedOffset</a>>, &'a str)></h4></section></summary><div class="docblock"><p>Parses a string from a user-specified format into a <code>DateTime<FixedOffset></code> value, and a |
| slice with the remaining portion of the string.</p> |
| <p>Note that this method <em>requires a timezone</em> in the input string. See |
| <a href="naive/struct.NaiveDateTime.html#method.parse_and_remainder" title="NaiveDateTime::parse_and_remainder"><code>NaiveDateTime::parse_and_remainder</code></a> for a version that does not |
| require a timezone in <code>s</code>. The returned <a href="struct.DateTime.html" title="DateTime"><code>DateTime</code></a> value will have a <a href="offset/struct.FixedOffset.html" title="FixedOffset"><code>FixedOffset</code></a> |
| reflecting the parsed timezone.</p> |
| <p>See the <a href="./format/strftime/index.html"><code>format::strftime</code> module</a> for supported format |
| sequences.</p> |
| <p>Similar to <a href="#method.parse_from_str"><code>parse_from_str</code></a>.</p> |
| <h5 id="example-6"><a href="#example-6">Example</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>(datetime, remainder) = DateTime::parse_and_remainder( |
| <span class="string">"2015-02-18 23:16:09 +0200 trailing text"</span>, <span class="string">"%Y-%m-%d %H:%M:%S %z"</span>).unwrap(); |
| <span class="macro">assert_eq!</span>( |
| datetime, |
| FixedOffset::east_opt(<span class="number">2</span><span class="kw-2">*</span><span class="number">3600</span>).unwrap().with_ymd_and_hms(<span class="number">2015</span>, <span class="number">2</span>, <span class="number">18</span>, <span class="number">23</span>, <span class="number">16</span>, <span class="number">9</span>).unwrap() |
| ); |
| <span class="macro">assert_eq!</span>(remainder, <span class="string">" trailing text"</span>);</code></pre></div> |
| </div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-DateTime%3CTz%3E-1" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#657-826">source</a><a href="#impl-DateTime%3CTz%3E-1" class="anchor"></a><h3 class="code-header">impl<Tz: <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>> <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz><span class="where fmt-newline">where<br> Tz::<a class="associatedtype" href="offset/trait.TimeZone.html#associatedtype.Offset" title="type chrono::offset::TimeZone::Offset">Offset</a>: Display,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.to_rfc2822" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#665-670">source</a><h4 class="code-header">pub fn <a href="#method.to_rfc2822" class="fnname">to_rfc2822</a>(&self) -> String</h4></section></summary><div class="docblock"><p>Returns an RFC 2822 date and time string such as <code>Tue, 1 Jul 2003 10:52:37 +0200</code>.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.to_rfc3339" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#676-681">source</a><h4 class="code-header">pub fn <a href="#method.to_rfc3339" class="fnname">to_rfc3339</a>(&self) -> String</h4></section></summary><div class="docblock"><p>Returns an RFC 3339 and ISO 8601 date and time string such as <code>1996-12-19T16:39:57-08:00</code>.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.to_rfc3339_opts" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#710-750">source</a><h4 class="code-header">pub fn <a href="#method.to_rfc3339_opts" class="fnname">to_rfc3339_opts</a>(&self, secform: <a class="enum" href="enum.SecondsFormat.html" title="enum chrono::SecondsFormat">SecondsFormat</a>, use_z: bool) -> String</h4></section></summary><div class="docblock"><p>Return an RFC 3339 and ISO 8601 date and time string with subseconds |
| formatted as per <code>SecondsFormat</code>.</p> |
| <p>If <code>use_z</code> is true and the timezone is UTC (offset 0), uses <code>Z</code> as |
| per <a href="format/enum.Fixed.html#variant.TimezoneOffsetColonZ" title="Fixed::TimezoneOffsetColonZ"><code>Fixed::TimezoneOffsetColonZ</code></a>. If <code>use_z</code> is false, uses |
| <a href="format/enum.Fixed.html#variant.TimezoneOffsetColon" title="Fixed::TimezoneOffsetColon"><code>Fixed::TimezoneOffsetColon</code></a></p> |
| <h5 id="examples"><a href="#examples">Examples</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>dt = NaiveDate::from_ymd_opt(<span class="number">2018</span>, <span class="number">1</span>, <span class="number">26</span>).unwrap().and_hms_micro_opt(<span class="number">18</span>, <span class="number">30</span>, <span class="number">9</span>, <span class="number">453_829</span>).unwrap().and_local_timezone(Utc).unwrap(); |
| <span class="macro">assert_eq!</span>(dt.to_rfc3339_opts(SecondsFormat::Millis, <span class="bool-val">false</span>), |
| <span class="string">"2018-01-26T18:30:09.453+00:00"</span>); |
| <span class="macro">assert_eq!</span>(dt.to_rfc3339_opts(SecondsFormat::Millis, <span class="bool-val">true</span>), |
| <span class="string">"2018-01-26T18:30:09.453Z"</span>); |
| <span class="macro">assert_eq!</span>(dt.to_rfc3339_opts(SecondsFormat::Secs, <span class="bool-val">true</span>), |
| <span class="string">"2018-01-26T18:30:09Z"</span>); |
| |
| <span class="kw">let </span>pst = FixedOffset::east_opt(<span class="number">8 </span>* <span class="number">60 </span>* <span class="number">60</span>).unwrap(); |
| <span class="kw">let </span>dt = pst.from_local_datetime(<span class="kw-2">&</span>NaiveDate::from_ymd_opt(<span class="number">2018</span>, <span class="number">1</span>, <span class="number">26</span>).unwrap().and_hms_micro_opt(<span class="number">10</span>, <span class="number">30</span>, <span class="number">9</span>, <span class="number">453_829</span>).unwrap()).unwrap(); |
| <span class="macro">assert_eq!</span>(dt.to_rfc3339_opts(SecondsFormat::Secs, <span class="bool-val">true</span>), |
| <span class="string">"2018-01-26T10:30:09+08:00"</span>);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.format_with_items" class="method has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#757-764">source</a><h4 class="code-header">pub fn <a href="#method.format_with_items" class="fnname">format_with_items</a><'a, I, B>(&self, items: I) -> <a class="struct" href="format/struct.DelayedFormat.html" title="struct chrono::format::DelayedFormat">DelayedFormat</a><I><span class="where fmt-newline">where<br> I: Iterator<Item = B> + Clone,<br> B: Borrow<<a class="enum" href="format/enum.Item.html" title="enum chrono::format::Item">Item</a><'a>>,</span></h4></section></summary><div class="docblock"><p>Formats the combined date and time with the specified formatting items.</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/chrono/datetime/mod.rs.html#782-784">source</a><h4 class="code-header">pub fn <a href="#method.format" class="fnname">format</a><'a>(&self, fmt: &'a str) -> <a class="struct" href="format/struct.DelayedFormat.html" title="struct chrono::format::DelayedFormat">DelayedFormat</a><<a class="struct" href="format/strftime/struct.StrftimeItems.html" title="struct chrono::format::strftime::StrftimeItems">StrftimeItems</a><'a>></h4></section></summary><div class="docblock"><p>Formats the combined date and time per the specified format string.</p> |
| <p>See the <a href="format/strftime/index.html" title="crate::format::strftime"><code>crate::format::strftime</code></a> module for the supported escape sequences.</p> |
| <h5 id="example-7"><a href="#example-7">Example</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::prelude::<span class="kw-2">*</span>; |
| |
| <span class="kw">let </span>date_time: DateTime<Utc> = Utc.with_ymd_and_hms(<span class="number">2017</span>, <span class="number">04</span>, <span class="number">02</span>, <span class="number">12</span>, <span class="number">50</span>, <span class="number">32</span>).unwrap(); |
| <span class="kw">let </span>formatted = <span class="macro">format!</span>(<span class="string">"{}"</span>, date_time.format(<span class="string">"%d/%m/%Y %H:%M"</span>)); |
| <span class="macro">assert_eq!</span>(formatted, <span class="string">"02/04/2017 12:50"</span>);</code></pre></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%3CDays%3E-for-DateTime%3CTz%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#1049-1055">source</a><a href="#impl-Add%3CDays%3E-for-DateTime%3CTz%3E" class="anchor"></a><h3 class="code-header">impl<Tz: <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>> Add<<a class="struct" href="naive/struct.Days.html" title="struct chrono::naive::Days">Days</a>> for <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Output-5" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Output-5" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Output</a> = <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h4></section></summary><div class='docblock'>The resulting type after applying the <code>+</code> operator.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.add-2" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#1052-1054">source</a><a href="#method.add-2" class="anchor"></a><h4 class="code-header">fn <a class="fnname">add</a>(self, days: <a class="struct" href="naive/struct.Days.html" title="struct chrono::naive::Days">Days</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-DateTime%3CTz%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#986-993">source</a><a href="#impl-Add%3CDuration%3E-for-DateTime%3CTz%3E" class="anchor"></a><h3 class="code-header">impl<Tz: <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>> Add<<a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>> for <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Output" 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.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h4></section></summary><div class='docblock'>The resulting type after applying the <code>+</code> operator.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.add" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#990-992">source</a><a href="#method.add" class="anchor"></a><h4 class="code-header">fn <a class="fnname">add</a>(self, rhs: <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">OldDuration</a>) -> <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h4></section></summary><div class='docblock'>Performs the <code>+</code> operation. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Add%3CFixedOffset%3E-for-DateTime%3CTz%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/offset/fixed.rs.html#227-234">source</a><a href="#impl-Add%3CFixedOffset%3E-for-DateTime%3CTz%3E" class="anchor"></a><h3 class="code-header">impl<Tz: <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>> Add<<a class="struct" href="offset/struct.FixedOffset.html" title="struct chrono::offset::FixedOffset">FixedOffset</a>> for <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Output-7" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Output-7" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Output</a> = <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h4></section></summary><div class='docblock'>The resulting type after applying the <code>+</code> operator.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.add-3" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/offset/fixed.rs.html#231-233">source</a><a href="#method.add-3" class="anchor"></a><h4 class="code-header">fn <a class="fnname">add</a>(self, rhs: <a class="struct" href="offset/struct.FixedOffset.html" title="struct chrono::offset::FixedOffset">FixedOffset</a>) -> <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h4></section></summary><div class='docblock'>Performs the <code>+</code> operation. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Add%3CMonths%3E-for-DateTime%3CTz%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#1005-1011">source</a><a href="#impl-Add%3CMonths%3E-for-DateTime%3CTz%3E" class="anchor"></a><h3 class="code-header">impl<Tz: <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>> Add<<a class="struct" href="struct.Months.html" title="struct chrono::Months">Months</a>> for <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Output-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.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h4></section></summary><div class='docblock'>The resulting type after applying the <code>+</code> operator.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.add-1" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#1008-1010">source</a><a href="#method.add-1" class="anchor"></a><h4 class="code-header">fn <a class="fnname">add</a>(self, rhs: <a class="struct" href="struct.Months.html" title="struct chrono::Months">Months</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-AddAssign%3CDuration%3E-for-DateTime%3CTz%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#995-1003">source</a><a href="#impl-AddAssign%3CDuration%3E-for-DateTime%3CTz%3E" class="anchor"></a><h3 class="code-header">impl<Tz: <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>> AddAssign<<a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>> for <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.add_assign" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#997-1002">source</a><a href="#method.add_assign" class="anchor"></a><h4 class="code-header">fn <a class="fnname">add_assign</a>(&mut self, rhs: <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">OldDuration</a>)</h4></section></summary><div class='docblock'>Performs the <code>+=</code> operation. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Clone-for-DateTime%3CTz%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#87">source</a><a href="#impl-Clone-for-DateTime%3CTz%3E" class="anchor"></a><h3 class="code-header">impl<Tz: Clone + <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>> Clone for <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz><span class="where fmt-newline">where<br> Tz::<a class="associatedtype" href="offset/trait.TimeZone.html#associatedtype.Offset" title="type chrono::offset::TimeZone::Offset">Offset</a>: Clone,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.clone" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#87">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.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></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-Datelike-for-DateTime%3CTz%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#828-900">source</a><a href="#impl-Datelike-for-DateTime%3CTz%3E" class="anchor"></a><h3 class="code-header">impl<Tz: <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>> <a class="trait" href="trait.Datelike.html" title="trait chrono::Datelike">Datelike</a> for <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.year" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#830-832">source</a><a href="#method.year" class="anchor"></a><h4 class="code-header">fn <a href="trait.Datelike.html#tymethod.year" class="fnname">year</a>(&self) -> i32</h4></section></summary><div class='docblock'>Returns the year number in the <a href="./naive/struct.NaiveDate.html#calendar-date">calendar date</a>.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.month" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#834-836">source</a><a href="#method.month" class="anchor"></a><h4 class="code-header">fn <a href="trait.Datelike.html#tymethod.month" class="fnname">month</a>(&self) -> u32</h4></section></summary><div class='docblock'>Returns the month number starting from 1. <a href="trait.Datelike.html#tymethod.month">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.month0" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#838-840">source</a><a href="#method.month0" class="anchor"></a><h4 class="code-header">fn <a href="trait.Datelike.html#tymethod.month0" class="fnname">month0</a>(&self) -> u32</h4></section></summary><div class='docblock'>Returns the month number starting from 0. <a href="trait.Datelike.html#tymethod.month0">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.day" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#842-844">source</a><a href="#method.day" class="anchor"></a><h4 class="code-header">fn <a href="trait.Datelike.html#tymethod.day" class="fnname">day</a>(&self) -> u32</h4></section></summary><div class='docblock'>Returns the day of month starting from 1. <a href="trait.Datelike.html#tymethod.day">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.day0" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#846-848">source</a><a href="#method.day0" class="anchor"></a><h4 class="code-header">fn <a href="trait.Datelike.html#tymethod.day0" class="fnname">day0</a>(&self) -> u32</h4></section></summary><div class='docblock'>Returns the day of month starting from 0. <a href="trait.Datelike.html#tymethod.day0">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ordinal" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#850-852">source</a><a href="#method.ordinal" class="anchor"></a><h4 class="code-header">fn <a href="trait.Datelike.html#tymethod.ordinal" class="fnname">ordinal</a>(&self) -> u32</h4></section></summary><div class='docblock'>Returns the day of year starting from 1. <a href="trait.Datelike.html#tymethod.ordinal">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ordinal0" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#854-856">source</a><a href="#method.ordinal0" class="anchor"></a><h4 class="code-header">fn <a href="trait.Datelike.html#tymethod.ordinal0" class="fnname">ordinal0</a>(&self) -> u32</h4></section></summary><div class='docblock'>Returns the day of year starting from 0. <a href="trait.Datelike.html#tymethod.ordinal0">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.weekday" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#858-860">source</a><a href="#method.weekday" class="anchor"></a><h4 class="code-header">fn <a href="trait.Datelike.html#tymethod.weekday" class="fnname">weekday</a>(&self) -> <a class="enum" href="enum.Weekday.html" title="enum chrono::Weekday">Weekday</a></h4></section></summary><div class='docblock'>Returns the day of week.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.iso_week" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#862-864">source</a><a href="#method.iso_week" class="anchor"></a><h4 class="code-header">fn <a href="trait.Datelike.html#tymethod.iso_week" class="fnname">iso_week</a>(&self) -> <a class="struct" href="naive/struct.IsoWeek.html" title="struct chrono::naive::IsoWeek">IsoWeek</a></h4></section></summary><div class='docblock'>Returns the ISO week.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.with_year" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#867-869">source</a><a href="#method.with_year" class="anchor"></a><h4 class="code-header">fn <a href="trait.Datelike.html#tymethod.with_year" class="fnname">with_year</a>(&self, year: i32) -> Option<<a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz>></h4></section></summary><div class='docblock'>Makes a new value with the year number changed. <a href="trait.Datelike.html#tymethod.with_year">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.with_month" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#872-874">source</a><a href="#method.with_month" class="anchor"></a><h4 class="code-header">fn <a href="trait.Datelike.html#tymethod.with_month" class="fnname">with_month</a>(&self, month: u32) -> Option<<a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz>></h4></section></summary><div class='docblock'>Makes a new value with the month number (starting from 1) changed. <a href="trait.Datelike.html#tymethod.with_month">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.with_month0" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#877-879">source</a><a href="#method.with_month0" class="anchor"></a><h4 class="code-header">fn <a href="trait.Datelike.html#tymethod.with_month0" class="fnname">with_month0</a>(&self, month0: u32) -> Option<<a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz>></h4></section></summary><div class='docblock'>Makes a new value with the month number (starting from 0) changed. <a href="trait.Datelike.html#tymethod.with_month0">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.with_day" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#882-884">source</a><a href="#method.with_day" class="anchor"></a><h4 class="code-header">fn <a href="trait.Datelike.html#tymethod.with_day" class="fnname">with_day</a>(&self, day: u32) -> Option<<a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz>></h4></section></summary><div class='docblock'>Makes a new value with the day of month (starting from 1) changed. <a href="trait.Datelike.html#tymethod.with_day">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.with_day0" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#887-889">source</a><a href="#method.with_day0" class="anchor"></a><h4 class="code-header">fn <a href="trait.Datelike.html#tymethod.with_day0" class="fnname">with_day0</a>(&self, day0: u32) -> Option<<a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz>></h4></section></summary><div class='docblock'>Makes a new value with the day of month (starting from 0) changed. <a href="trait.Datelike.html#tymethod.with_day0">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.with_ordinal" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#892-894">source</a><a href="#method.with_ordinal" class="anchor"></a><h4 class="code-header">fn <a href="trait.Datelike.html#tymethod.with_ordinal" class="fnname">with_ordinal</a>(&self, ordinal: u32) -> Option<<a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz>></h4></section></summary><div class='docblock'>Makes a new value with the day of year (starting from 1) changed. <a href="trait.Datelike.html#tymethod.with_ordinal">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.with_ordinal0" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#897-899">source</a><a href="#method.with_ordinal0" class="anchor"></a><h4 class="code-header">fn <a href="trait.Datelike.html#tymethod.with_ordinal0" class="fnname">with_ordinal0</a>(&self, ordinal0: u32) -> Option<<a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz>></h4></section></summary><div class='docblock'>Makes a new value with the day of year (starting from 0) changed. <a href="trait.Datelike.html#tymethod.with_ordinal0">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.year_ce" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/traits.rs.html#11-18">source</a><a href="#method.year_ce" class="anchor"></a><h4 class="code-header">fn <a href="trait.Datelike.html#method.year_ce" class="fnname">year_ce</a>(&self) -> (bool, u32)</h4></section></summary><div class='docblock'>Returns the absolute year number starting from 1 with a boolean flag, |
| which is false when the year predates the epoch (BCE/BC) and true otherwise (CE/AD). <a href="trait.Datelike.html#method.year_ce">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.num_days_from_ce" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/traits.rs.html#103-118">source</a><a href="#method.num_days_from_ce" class="anchor"></a><h4 class="code-header">fn <a href="trait.Datelike.html#method.num_days_from_ce" class="fnname">num_days_from_ce</a>(&self) -> i32</h4></section></summary><div class='docblock'>Counts the days in the proleptic Gregorian calendar, with January 1, Year 1 (CE) as day 1. <a href="trait.Datelike.html#method.num_days_from_ce">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Debug-for-DateTime%3CTz%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#1065-1070">source</a><a href="#impl-Debug-for-DateTime%3CTz%3E" class="anchor"></a><h3 class="code-header">impl<Tz: <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>> Debug for <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.fmt" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#1066-1069">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-Default-for-DateTime%3CFixedOffset%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#468-472">source</a><a href="#impl-Default-for-DateTime%3CFixedOffset%3E" class="anchor"></a><h3 class="code-header">impl Default for <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><<a class="struct" href="offset/struct.FixedOffset.html" title="struct chrono::offset::FixedOffset">FixedOffset</a>></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.default-1" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#469-471">source</a><a href="#method.default-1" class="anchor"></a><h4 class="code-header">fn <a class="fnname">default</a>() -> Self</h4></section></summary><div class='docblock'>Returns the “default value” for a type. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Default-for-DateTime%3CUtc%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#454-458">source</a><a href="#impl-Default-for-DateTime%3CUtc%3E" class="anchor"></a><h3 class="code-header">impl Default for <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><<a class="struct" href="offset/struct.Utc.html" title="struct chrono::offset::Utc">Utc</a>></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.default" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#455-457">source</a><a href="#method.default" class="anchor"></a><h4 class="code-header">fn <a class="fnname">default</a>() -> Self</h4></section></summary><div class='docblock'>Returns the “default value” for a type. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Display-for-DateTime%3CTz%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#1072-1081">source</a><a href="#impl-Display-for-DateTime%3CTz%3E" class="anchor"></a><h3 class="code-header">impl<Tz: <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>> Display for <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz><span class="where fmt-newline">where<br> Tz::<a class="associatedtype" href="offset/trait.TimeZone.html#associatedtype.Offset" title="type chrono::offset::TimeZone::Offset">Offset</a>: Display,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.fmt-1" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#1076-1080">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-DurationRound-for-DateTime%3CTz%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/round.rs.html#148-158">source</a><a href="#impl-DurationRound-for-DateTime%3CTz%3E" class="anchor"></a><h3 class="code-header">impl<Tz: <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>> <a class="trait" href="trait.DurationRound.html" title="trait chrono::DurationRound">DurationRound</a> for <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Err-2" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Err-2" class="anchor"></a><h4 class="code-header">type <a href="trait.DurationRound.html#associatedtype.Err" class="associatedtype">Err</a> = <a class="enum" href="enum.RoundingError.html" title="enum chrono::RoundingError">RoundingError</a></h4></section></summary><div class='docblock'>Error that can occur in rounding or truncating</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.duration_round" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/round.rs.html#151-153">source</a><a href="#method.duration_round" class="anchor"></a><h4 class="code-header">fn <a href="trait.DurationRound.html#tymethod.duration_round" class="fnname">duration_round</a>(self, duration: <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>) -> Result<Self, Self::<a class="associatedtype" href="trait.DurationRound.html#associatedtype.Err" title="type chrono::DurationRound::Err">Err</a>></h4></section></summary><div class='docblock'>Return a copy rounded by Duration. <a href="trait.DurationRound.html#tymethod.duration_round">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.duration_trunc" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/round.rs.html#155-157">source</a><a href="#method.duration_trunc" class="anchor"></a><h4 class="code-header">fn <a href="trait.DurationRound.html#tymethod.duration_trunc" class="fnname">duration_trunc</a>(self, duration: <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>) -> Result<Self, Self::<a class="associatedtype" href="trait.DurationRound.html#associatedtype.Err" title="type chrono::DurationRound::Err">Err</a>></h4></section></summary><div class='docblock'>Return a copy truncated by Duration. <a href="trait.DurationRound.html#tymethod.duration_trunc">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-From%3CDateTime%3CFixedOffset%3E%3E-for-DateTime%3CUtc%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#498-506">source</a><a href="#impl-From%3CDateTime%3CFixedOffset%3E%3E-for-DateTime%3CUtc%3E" class="anchor"></a><h3 class="code-header">impl From<<a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><<a class="struct" href="offset/struct.FixedOffset.html" title="struct chrono::offset::FixedOffset">FixedOffset</a>>> for <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><<a class="struct" href="offset/struct.Utc.html" title="struct chrono::offset::Utc">Utc</a>></h3></section></summary><div class="docblock"><p>Convert a <code>DateTime<FixedOffset></code> instance into a <code>DateTime<Utc></code> instance.</p> |
| </div><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from-1" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#503-505">source</a><a href="#method.from-1" class="anchor"></a><h4 class="code-header">fn <a class="fnname">from</a>(src: <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><<a class="struct" href="offset/struct.FixedOffset.html" title="struct chrono::offset::FixedOffset">FixedOffset</a>>) -> Self</h4></section></summary><div class="docblock"><p>Convert this <code>DateTime<FixedOffset></code> instance into a <code>DateTime<Utc></code> instance.</p> |
| <p>Conversion is performed via <a href="struct.DateTime.html#method.with_timezone" title="DateTime::with_timezone"><code>DateTime::with_timezone</code></a>, accounting for the timezone |
| difference.</p> |
| </div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-From%3CDateTime%3CTz%3E%3E-for-SystemTime" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#1158-1171">source</a><a href="#impl-From%3CDateTime%3CTz%3E%3E-for-SystemTime" class="anchor"></a><h3 class="code-header">impl<Tz: <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>> From<<a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz>> for SystemTime</h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from-3" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#1159-1170">source</a><a href="#method.from-3" class="anchor"></a><h4 class="code-header">fn <a class="fnname">from</a>(dt: <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz>) -> SystemTime</h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-From%3CDateTime%3CUtc%3E%3E-for-DateTime%3CFixedOffset%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#475-483">source</a><a href="#impl-From%3CDateTime%3CUtc%3E%3E-for-DateTime%3CFixedOffset%3E" class="anchor"></a><h3 class="code-header">impl From<<a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><<a class="struct" href="offset/struct.Utc.html" title="struct chrono::offset::Utc">Utc</a>>> for <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><<a class="struct" href="offset/struct.FixedOffset.html" title="struct chrono::offset::FixedOffset">FixedOffset</a>></h3></section></summary><div class="docblock"><p>Convert a <code>DateTime<Utc></code> instance into a <code>DateTime<FixedOffset></code> instance.</p> |
| </div><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#480-482">source</a><a href="#method.from" class="anchor"></a><h4 class="code-header">fn <a class="fnname">from</a>(src: <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><<a class="struct" href="offset/struct.Utc.html" title="struct chrono::offset::Utc">Utc</a>>) -> Self</h4></section></summary><div class="docblock"><p>Convert this <code>DateTime<Utc></code> instance into a <code>DateTime<FixedOffset></code> instance.</p> |
| <p>Conversion is done via <a href="struct.DateTime.html#method.with_timezone" title="DateTime::with_timezone"><code>DateTime::with_timezone</code></a>. Note that the converted value returned by |
| this will be created with a fixed timezone offset of 0.</p> |
| </div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-From%3CSystemTime%3E-for-DateTime%3CUtc%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#1129-1146">source</a><a href="#impl-From%3CSystemTime%3E-for-DateTime%3CUtc%3E" class="anchor"></a><h3 class="code-header">impl From<SystemTime> for <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><<a class="struct" href="offset/struct.Utc.html" title="struct chrono::offset::Utc">Utc</a>></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from-2" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#1130-1145">source</a><a href="#method.from-2" class="anchor"></a><h4 class="code-header">fn <a class="fnname">from</a>(t: SystemTime) -> <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><<a class="struct" href="offset/struct.Utc.html" title="struct chrono::offset::Utc">Utc</a>></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-FromStr-for-DateTime%3CFixedOffset%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/format/parse.rs.html#512-553">source</a><a href="#impl-FromStr-for-DateTime%3CFixedOffset%3E" class="anchor"></a><h3 class="code-header">impl FromStr for <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><<a class="struct" href="offset/struct.FixedOffset.html" title="struct chrono::offset::FixedOffset">FixedOffset</a>></h3></section></summary><div class="docblock"><p>Accepts a relaxed form of RFC3339. |
| A space or a ‘T’ are acepted as the separator between the date and time |
| parts. Additional spaces are allowed between each component.</p> |
| <p>All of these examples are equivalent:</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="string">"2012-12-12T12:12:12Z"</span>.parse::<DateTime<FixedOffset>>()<span class="question-mark">?</span>; |
| <span class="string">"2012-12-12 12:12:12Z"</span>.parse::<DateTime<FixedOffset>>()<span class="question-mark">?</span>; |
| <span class="string">"2012- 12-12T12: 12:12Z"</span>.parse::<DateTime<FixedOffset>>()<span class="question-mark">?</span>;</code></pre></div> |
| </div><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Err-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Err-1" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Err</a> = <a class="struct" href="format/struct.ParseError.html" title="struct chrono::format::ParseError">ParseError</a></h4></section></summary><div class='docblock'>The associated error which can be returned from parsing.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from_str-1" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/format/parse.rs.html#515-552">source</a><a href="#method.from_str-1" class="anchor"></a><h4 class="code-header">fn <a class="fnname">from_str</a>(s: &str) -> <a class="type" href="format/type.ParseResult.html" title="type chrono::format::ParseResult">ParseResult</a><<a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><<a class="struct" href="offset/struct.FixedOffset.html" title="struct chrono::offset::FixedOffset">FixedOffset</a>>></h4></section></summary><div class='docblock'>Parses a string <code>s</code> to return a value of this type. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-FromStr-for-DateTime%3CUtc%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#1096-1102">source</a><a href="#impl-FromStr-for-DateTime%3CUtc%3E" class="anchor"></a><h3 class="code-header">impl FromStr for <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><<a class="struct" href="offset/struct.Utc.html" title="struct chrono::offset::Utc">Utc</a>></h3></section></summary><div class="docblock"><p>Accepts a relaxed form of RFC3339. |
| A space or a ‘T’ are acepted as the separator between the date and time |
| parts.</p> |
| <p>All of these examples are equivalent:</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="string">"2012-12-12T12:12:12Z"</span>.parse::<DateTime<Utc>>()<span class="question-mark">?</span>; |
| <span class="string">"2012-12-12 12:12:12Z"</span>.parse::<DateTime<Utc>>()<span class="question-mark">?</span>; |
| <span class="string">"2012-12-12 12:12:12+0000"</span>.parse::<DateTime<Utc>>()<span class="question-mark">?</span>; |
| <span class="string">"2012-12-12 12:12:12+00:00"</span>.parse::<DateTime<Utc>>()<span class="question-mark">?</span>;</code></pre></div> |
| </div><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Err" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Err" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Err</a> = <a class="struct" href="format/struct.ParseError.html" title="struct chrono::format::ParseError">ParseError</a></h4></section></summary><div class='docblock'>The associated error which can be returned from parsing.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from_str" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#1099-1101">source</a><a href="#method.from_str" class="anchor"></a><h4 class="code-header">fn <a class="fnname">from_str</a>(s: &str) -> <a class="type" href="format/type.ParseResult.html" title="type chrono::format::ParseResult">ParseResult</a><<a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><<a class="struct" href="offset/struct.Utc.html" title="struct chrono::offset::Utc">Utc</a>>></h4></section></summary><div class='docblock'>Parses a string <code>s</code> to return a value of this type. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Hash-for-DateTime%3CTz%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#980-984">source</a><a href="#impl-Hash-for-DateTime%3CTz%3E" class="anchor"></a><h3 class="code-header">impl<Tz: <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>> Hash for <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.hash" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#981-983">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-DateTime%3CTz%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#974-978">source</a><a href="#impl-Ord-for-DateTime%3CTz%3E" class="anchor"></a><h3 class="code-header">impl<Tz: <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>> Ord for <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.cmp" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#975-977">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.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz>) -> 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%3CDateTime%3CTz2%3E%3E-for-DateTime%3CTz%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#945-949">source</a><a href="#impl-PartialEq%3CDateTime%3CTz2%3E%3E-for-DateTime%3CTz%3E" class="anchor"></a><h3 class="code-header">impl<Tz: <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>, Tz2: <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>> PartialEq<<a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz2>> for <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.eq" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#946-948">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.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz2>) -> 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%3CDateTime%3CTz2%3E%3E-for-DateTime%3CTz%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#953-972">source</a><a href="#impl-PartialOrd%3CDateTime%3CTz2%3E%3E-for-DateTime%3CTz%3E" class="anchor"></a><h3 class="code-header">impl<Tz: <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>, Tz2: <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>> PartialOrd<<a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz2>> for <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.partial_cmp" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#969-971">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.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz2>) -> Option<Ordering></h4></section></summary><div class="docblock"><p>Compare two DateTimes based on their true time, ignoring time zones</p> |
| <h5 id="example-8"><a href="#example-8">Example</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::prelude::<span class="kw-2">*</span>; |
| |
| <span class="kw">let </span>earlier = Utc.with_ymd_and_hms(<span class="number">2015</span>, <span class="number">5</span>, <span class="number">15</span>, <span class="number">2</span>, <span class="number">0</span>, <span class="number">0</span>).unwrap().with_timezone(<span class="kw-2">&</span>FixedOffset::west_opt(<span class="number">1 </span>* <span class="number">3600</span>).unwrap()); |
| <span class="kw">let </span>later = Utc.with_ymd_and_hms(<span class="number">2015</span>, <span class="number">5</span>, <span class="number">15</span>, <span class="number">3</span>, <span class="number">0</span>, <span class="number">0</span>).unwrap().with_timezone(<span class="kw-2">&</span>FixedOffset::west_opt(<span class="number">5 </span>* <span class="number">3600</span>).unwrap()); |
| |
| <span class="macro">assert_eq!</span>(earlier.to_string(), <span class="string">"2015-05-15 01:00:00 -01:00"</span>); |
| <span class="macro">assert_eq!</span>(later.to_string(), <span class="string">"2015-05-14 22:00:00 -05:00"</span>); |
| |
| <span class="macro">assert!</span>(later > earlier);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.lt" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.lt" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">lt</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests less than (for <code>self</code> and <code>other</code>) and is used by the <code><</code> operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.le" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.le" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">le</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests less than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code><=</code> |
| operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.gt" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.gt" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">gt</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests greater than (for <code>self</code> and <code>other</code>) and is used by the <code>></code> operator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ge" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.ge" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">ge</a>(&self, other: &Rhs) -> bool</h4></section></summary><div class='docblock'>This method tests greater than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code>>=</code> |
| operator. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Sub%3CDateTime%3CTz%3E%3E-for-DateTime%3CTz%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#1040-1047">source</a><a href="#impl-Sub%3CDateTime%3CTz%3E%3E-for-DateTime%3CTz%3E" class="anchor"></a><h3 class="code-header">impl<Tz: <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>> Sub<<a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz>> for <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Output-4" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Output-4" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Output</a> = <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a></h4></section></summary><div class='docblock'>The resulting type after applying the <code>-</code> operator.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.sub-2" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#1044-1046">source</a><a href="#method.sub-2" class="anchor"></a><h4 class="code-header">fn <a class="fnname">sub</a>(self, rhs: <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz>) -> <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">OldDuration</a></h4></section></summary><div class='docblock'>Performs the <code>-</code> operation. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Sub%3CDays%3E-for-DateTime%3CTz%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#1057-1063">source</a><a href="#impl-Sub%3CDays%3E-for-DateTime%3CTz%3E" class="anchor"></a><h3 class="code-header">impl<Tz: <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>> Sub<<a class="struct" href="naive/struct.Days.html" title="struct chrono::naive::Days">Days</a>> for <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Output-6" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Output-6" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Output</a> = <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h4></section></summary><div class='docblock'>The resulting type after applying the <code>-</code> operator.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.sub-3" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#1060-1062">source</a><a href="#method.sub-3" class="anchor"></a><h4 class="code-header">fn <a class="fnname">sub</a>(self, days: <a class="struct" href="naive/struct.Days.html" title="struct chrono::naive::Days">Days</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-DateTime%3CTz%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#1013-1020">source</a><a href="#impl-Sub%3CDuration%3E-for-DateTime%3CTz%3E" class="anchor"></a><h3 class="code-header">impl<Tz: <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>> Sub<<a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>> for <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Output-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.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h4></section></summary><div class='docblock'>The resulting type after applying the <code>-</code> operator.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.sub" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#1017-1019">source</a><a href="#method.sub" class="anchor"></a><h4 class="code-header">fn <a class="fnname">sub</a>(self, rhs: <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">OldDuration</a>) -> <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h4></section></summary><div class='docblock'>Performs the <code>-</code> operation. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Sub%3CFixedOffset%3E-for-DateTime%3CTz%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/offset/fixed.rs.html#236-243">source</a><a href="#impl-Sub%3CFixedOffset%3E-for-DateTime%3CTz%3E" class="anchor"></a><h3 class="code-header">impl<Tz: <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>> Sub<<a class="struct" href="offset/struct.FixedOffset.html" title="struct chrono::offset::FixedOffset">FixedOffset</a>> for <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Output-8" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Output-8" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Output</a> = <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h4></section></summary><div class='docblock'>The resulting type after applying the <code>-</code> operator.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.sub-4" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/offset/fixed.rs.html#240-242">source</a><a href="#method.sub-4" class="anchor"></a><h4 class="code-header">fn <a class="fnname">sub</a>(self, rhs: <a class="struct" href="offset/struct.FixedOffset.html" title="struct chrono::offset::FixedOffset">FixedOffset</a>) -> <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h4></section></summary><div class='docblock'>Performs the <code>-</code> operation. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Sub%3CMonths%3E-for-DateTime%3CTz%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#1032-1038">source</a><a href="#impl-Sub%3CMonths%3E-for-DateTime%3CTz%3E" class="anchor"></a><h3 class="code-header">impl<Tz: <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>> Sub<<a class="struct" href="struct.Months.html" title="struct chrono::Months">Months</a>> for <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Output-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.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h4></section></summary><div class='docblock'>The resulting type after applying the <code>-</code> operator.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.sub-1" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#1035-1037">source</a><a href="#method.sub-1" class="anchor"></a><h4 class="code-header">fn <a class="fnname">sub</a>(self, rhs: <a class="struct" href="struct.Months.html" title="struct chrono::Months">Months</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-SubAssign%3CDuration%3E-for-DateTime%3CTz%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#1022-1030">source</a><a href="#impl-SubAssign%3CDuration%3E-for-DateTime%3CTz%3E" class="anchor"></a><h3 class="code-header">impl<Tz: <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>> SubAssign<<a class="struct" href="struct.Duration.html" title="struct chrono::Duration">Duration</a>> for <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.sub_assign" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#1024-1029">source</a><a href="#method.sub_assign" class="anchor"></a><h4 class="code-header">fn <a class="fnname">sub_assign</a>(&mut self, rhs: <a class="struct" href="struct.Duration.html" title="struct chrono::Duration">OldDuration</a>)</h4></section></summary><div class='docblock'>Performs the <code>-=</code> operation. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Timelike-for-DateTime%3CTz%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#902-939">source</a><a href="#impl-Timelike-for-DateTime%3CTz%3E" class="anchor"></a><h3 class="code-header">impl<Tz: <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>> <a class="trait" href="trait.Timelike.html" title="trait chrono::Timelike">Timelike</a> for <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.hour" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#904-906">source</a><a href="#method.hour" class="anchor"></a><h4 class="code-header">fn <a href="trait.Timelike.html#tymethod.hour" class="fnname">hour</a>(&self) -> u32</h4></section></summary><div class='docblock'>Returns the hour number from 0 to 23.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.minute" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#908-910">source</a><a href="#method.minute" class="anchor"></a><h4 class="code-header">fn <a href="trait.Timelike.html#tymethod.minute" class="fnname">minute</a>(&self) -> u32</h4></section></summary><div class='docblock'>Returns the minute number from 0 to 59.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.second" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#912-914">source</a><a href="#method.second" class="anchor"></a><h4 class="code-header">fn <a href="trait.Timelike.html#tymethod.second" class="fnname">second</a>(&self) -> u32</h4></section></summary><div class='docblock'>Returns the second number from 0 to 59.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.nanosecond" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#916-918">source</a><a href="#method.nanosecond" class="anchor"></a><h4 class="code-header">fn <a href="trait.Timelike.html#tymethod.nanosecond" class="fnname">nanosecond</a>(&self) -> u32</h4></section></summary><div class='docblock'>Returns the number of nanoseconds since the whole non-leap second. |
| The range from 1,000,000,000 to 1,999,999,999 represents |
| the <a href="./naive/struct.NaiveTime.html#leap-second-handling">leap second</a>. <a href="trait.Timelike.html#tymethod.nanosecond">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.with_hour" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#921-923">source</a><a href="#method.with_hour" class="anchor"></a><h4 class="code-header">fn <a href="trait.Timelike.html#tymethod.with_hour" class="fnname">with_hour</a>(&self, hour: u32) -> Option<<a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz>></h4></section></summary><div class='docblock'>Makes a new value with the hour number changed. <a href="trait.Timelike.html#tymethod.with_hour">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.with_minute" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#926-928">source</a><a href="#method.with_minute" class="anchor"></a><h4 class="code-header">fn <a href="trait.Timelike.html#tymethod.with_minute" class="fnname">with_minute</a>(&self, min: u32) -> Option<<a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz>></h4></section></summary><div class='docblock'>Makes a new value with the minute number changed. <a href="trait.Timelike.html#tymethod.with_minute">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.with_second" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#931-933">source</a><a href="#method.with_second" class="anchor"></a><h4 class="code-header">fn <a href="trait.Timelike.html#tymethod.with_second" class="fnname">with_second</a>(&self, sec: u32) -> Option<<a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz>></h4></section></summary><div class='docblock'>Makes a new value with the second number changed. <a href="trait.Timelike.html#tymethod.with_second">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.with_nanosecond" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#936-938">source</a><a href="#method.with_nanosecond" class="anchor"></a><h4 class="code-header">fn <a href="trait.Timelike.html#tymethod.with_nanosecond" class="fnname">with_nanosecond</a>(&self, nano: u32) -> Option<<a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz>></h4></section></summary><div class='docblock'>Makes a new value with nanoseconds since the whole non-leap second changed. <a href="trait.Timelike.html#tymethod.with_nanosecond">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.hour12" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/traits.rs.html#129-136">source</a><a href="#method.hour12" class="anchor"></a><h4 class="code-header">fn <a href="trait.Timelike.html#method.hour12" class="fnname">hour12</a>(&self) -> (bool, u32)</h4></section></summary><div class='docblock'>Returns the hour number from 1 to 12 with a boolean flag, |
| which is false for AM and true for PM. <a href="trait.Timelike.html#method.hour12">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.num_seconds_from_midnight" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/chrono/traits.rs.html#175-177">source</a><a href="#method.num_seconds_from_midnight" class="anchor"></a><h4 class="code-header">fn <a href="trait.Timelike.html#method.num_seconds_from_midnight" class="fnname">num_seconds_from_midnight</a>(&self) -> u32</h4></section></summary><div class='docblock'>Returns the number of non-leap seconds past the last midnight.</div></details></div></details><section id="impl-Copy-for-DateTime%3CTz%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#942">source</a><a href="#impl-Copy-for-DateTime%3CTz%3E" class="anchor"></a><h3 class="code-header">impl<Tz: <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>> Copy for <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz><span class="where fmt-newline">where<br> <Tz as <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>>::<a class="associatedtype" href="offset/trait.TimeZone.html#associatedtype.Offset" title="type chrono::offset::TimeZone::Offset">Offset</a>: Copy,</span></h3></section><section id="impl-Eq-for-DateTime%3CTz%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#951">source</a><a href="#impl-Eq-for-DateTime%3CTz%3E" class="anchor"></a><h3 class="code-header">impl<Tz: <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>> Eq for <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz></h3></section><section id="impl-Send-for-DateTime%3CTz%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/chrono/datetime/mod.rs.html#943">source</a><a href="#impl-Send-for-DateTime%3CTz%3E" class="anchor"></a><h3 class="code-header">impl<Tz: <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>> Send for <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz><span class="where fmt-newline">where<br> <Tz as <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>>::<a class="associatedtype" href="offset/trait.TimeZone.html#associatedtype.Offset" title="type chrono::offset::TimeZone::Offset">Offset</a>: Send,</span></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-DateTime%3CTz%3E" class="impl has-srclink"><a href="#impl-RefUnwindSafe-for-DateTime%3CTz%3E" class="anchor"></a><h3 class="code-header">impl<Tz> RefUnwindSafe for <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz><span class="where fmt-newline">where<br> <Tz as <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>>::<a class="associatedtype" href="offset/trait.TimeZone.html#associatedtype.Offset" title="type chrono::offset::TimeZone::Offset">Offset</a>: RefUnwindSafe,</span></h3></section><section id="impl-Sync-for-DateTime%3CTz%3E" class="impl has-srclink"><a href="#impl-Sync-for-DateTime%3CTz%3E" class="anchor"></a><h3 class="code-header">impl<Tz> Sync for <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz><span class="where fmt-newline">where<br> <Tz as <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>>::<a class="associatedtype" href="offset/trait.TimeZone.html#associatedtype.Offset" title="type chrono::offset::TimeZone::Offset">Offset</a>: Sync,</span></h3></section><section id="impl-Unpin-for-DateTime%3CTz%3E" class="impl has-srclink"><a href="#impl-Unpin-for-DateTime%3CTz%3E" class="anchor"></a><h3 class="code-header">impl<Tz> Unpin for <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz><span class="where fmt-newline">where<br> <Tz as <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>>::<a class="associatedtype" href="offset/trait.TimeZone.html#associatedtype.Offset" title="type chrono::offset::TimeZone::Offset">Offset</a>: Unpin,</span></h3></section><section id="impl-UnwindSafe-for-DateTime%3CTz%3E" class="impl has-srclink"><a href="#impl-UnwindSafe-for-DateTime%3CTz%3E" class="anchor"></a><h3 class="code-header">impl<Tz> UnwindSafe for <a class="struct" href="struct.DateTime.html" title="struct chrono::DateTime">DateTime</a><Tz><span class="where fmt-newline">where<br> <Tz as <a class="trait" href="offset/trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a>>::<a class="associatedtype" href="offset/trait.TimeZone.html#associatedtype.Offset" title="type chrono::offset::TimeZone::Offset">Offset</a>: UnwindSafe,</span></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-DateTime%3CTz%3E" class="impl has-srclink"><a href="#impl-Any-for-DateTime%3CTz%3E" 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-DateTime%3CTz%3E" class="impl has-srclink"><a href="#impl-Borrow%3CT%3E-for-DateTime%3CTz%3E" 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-DateTime%3CTz%3E" class="impl has-srclink"><a href="#impl-BorrowMut%3CT%3E-for-DateTime%3CTz%3E" 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-DateTime%3CTz%3E" class="impl has-srclink"><a href="#impl-From%3CT%3E-for-DateTime%3CTz%3E" 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-4" 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-4" 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-DateTime%3CTz%3E" class="impl has-srclink"><a href="#impl-Into%3CU%3E-for-DateTime%3CTz%3E" 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-DateTime%3CTz%3E" class="impl has-srclink"><a href="#impl-ToOwned-for-DateTime%3CTz%3E" 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-DateTime%3CTz%3E" class="impl has-srclink"><a href="#impl-ToString-for-DateTime%3CTz%3E" 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-DateTime%3CTz%3E" class="impl has-srclink"><a href="#impl-TryFrom%3CU%3E-for-DateTime%3CTz%3E" class="anchor"></a><h3 class="code-header">impl<T, U> TryFrom<U> for T<span class="where fmt-newline">where<br> U: Into<T>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error-1" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Error</a> = Infallible</h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl has-srclink"><span class="since rightside" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span><a href="#method.try_from" class="anchor"></a><h4 class="code-header">fn <a class="fnname">try_from</a>(value: U) -> Result<T, <T as TryFrom<U>>::Error></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-DateTime%3CTz%3E" class="impl has-srclink"><a href="#impl-TryInto%3CU%3E-for-DateTime%3CTz%3E" class="anchor"></a><h3 class="code-header">impl<T, U> TryInto<U> for T<span class="where fmt-newline">where<br> U: TryFrom<T>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Error</a> = <U as TryFrom<T>>::Error</h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl has-srclink"><span class="since rightside" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span><a href="#method.try_into" class="anchor"></a><h4 class="code-header">fn <a class="fnname">try_into</a>(self) -> Result<U, <U as TryFrom<T>>::Error></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details></div></section></div></main><div id="rustdoc-vars" data-root-path="../" data-current-crate="chrono" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.66.0-nightly (5c8bff74b 2022-10-21)" ></div></body></html> |