blob: 8ca80c7f5821e46aabf50a522c6d83f7cd5f582a [file] [log] [blame]
<!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 calendar date without timezone. Allows for every proleptic Gregorian date from Jan 1, 262145 BCE to Dec 31, 262143 CE. Also supports the conversion from ISO 8601 ordinal and week date."><meta name="keywords" content="rust, rustlang, rust-lang, NaiveDate"><title>NaiveDate in chrono::naive - 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">&#9776;</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="#">NaiveDate</a></h2><div class="sidebar-elems"><section><h3><a href="#implementations">Associated Constants</a></h3><ul class="block"><li><a href="#associatedconstant.MAX">MAX</a></li><li><a href="#associatedconstant.MIN">MIN</a></li></ul><h3><a href="#implementations">Methods</a></h3><ul class="block"><li><a href="#method.and_hms">and_hms</a></li><li><a href="#method.and_hms_micro">and_hms_micro</a></li><li><a href="#method.and_hms_micro_opt">and_hms_micro_opt</a></li><li><a href="#method.and_hms_milli">and_hms_milli</a></li><li><a href="#method.and_hms_milli_opt">and_hms_milli_opt</a></li><li><a href="#method.and_hms_nano">and_hms_nano</a></li><li><a href="#method.and_hms_nano_opt">and_hms_nano_opt</a></li><li><a href="#method.and_hms_opt">and_hms_opt</a></li><li><a href="#method.and_time">and_time</a></li><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.format">format</a></li><li><a href="#method.format_with_items">format_with_items</a></li><li><a href="#method.from_isoywd">from_isoywd</a></li><li><a href="#method.from_isoywd_opt">from_isoywd_opt</a></li><li><a href="#method.from_num_days_from_ce">from_num_days_from_ce</a></li><li><a href="#method.from_num_days_from_ce_opt">from_num_days_from_ce_opt</a></li><li><a href="#method.from_weekday_of_month">from_weekday_of_month</a></li><li><a href="#method.from_weekday_of_month_opt">from_weekday_of_month_opt</a></li><li><a href="#method.from_ymd">from_ymd</a></li><li><a href="#method.from_ymd_opt">from_ymd_opt</a></li><li><a href="#method.from_yo">from_yo</a></li><li><a href="#method.from_yo_opt">from_yo_opt</a></li><li><a href="#method.iter_days">iter_days</a></li><li><a href="#method.iter_weeks">iter_weeks</a></li><li><a href="#method.parse_and_remainder">parse_and_remainder</a></li><li><a href="#method.parse_from_str">parse_from_str</a></li><li><a href="#method.pred">pred</a></li><li><a href="#method.pred_opt">pred_opt</a></li><li><a href="#method.signed_duration_since">signed_duration_since</a></li><li><a href="#method.succ">succ</a></li><li><a href="#method.succ_opt">succ_opt</a></li><li><a href="#method.week">week</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-NaiveDate">Add&lt;Days&gt;</a></li><li><a href="#impl-Add%3CDuration%3E-for-NaiveDate">Add&lt;Duration&gt;</a></li><li><a href="#impl-Add%3CMonths%3E-for-NaiveDate">Add&lt;Months&gt;</a></li><li><a href="#impl-AddAssign%3CDuration%3E-for-NaiveDate">AddAssign&lt;Duration&gt;</a></li><li><a href="#impl-Clone-for-NaiveDate">Clone</a></li><li><a href="#impl-Copy-for-NaiveDate">Copy</a></li><li><a href="#impl-Datelike-for-NaiveDate">Datelike</a></li><li><a href="#impl-Debug-for-NaiveDate">Debug</a></li><li><a href="#impl-Default-for-NaiveDate">Default</a></li><li><a href="#impl-Display-for-NaiveDate">Display</a></li><li><a href="#impl-Eq-for-NaiveDate">Eq</a></li><li><a href="#impl-From%3CNaiveDateTime%3E-for-NaiveDate">From&lt;NaiveDateTime&gt;</a></li><li><a href="#impl-FromStr-for-NaiveDate">FromStr</a></li><li><a href="#impl-Hash-for-NaiveDate">Hash</a></li><li><a href="#impl-Ord-for-NaiveDate">Ord</a></li><li><a href="#impl-PartialEq%3CNaiveDate%3E-for-NaiveDate">PartialEq&lt;NaiveDate&gt;</a></li><li><a href="#impl-PartialOrd%3CNaiveDate%3E-for-NaiveDate">PartialOrd&lt;NaiveDate&gt;</a></li><li><a href="#impl-StructuralEq-for-NaiveDate">StructuralEq</a></li><li><a href="#impl-StructuralPartialEq-for-NaiveDate">StructuralPartialEq</a></li><li><a href="#impl-Sub%3CDays%3E-for-NaiveDate">Sub&lt;Days&gt;</a></li><li><a href="#impl-Sub%3CDuration%3E-for-NaiveDate">Sub&lt;Duration&gt;</a></li><li><a href="#impl-Sub%3CMonths%3E-for-NaiveDate">Sub&lt;Months&gt;</a></li><li><a href="#impl-Sub%3CNaiveDate%3E-for-NaiveDate">Sub&lt;NaiveDate&gt;</a></li><li><a href="#impl-SubAssign%3CDuration%3E-for-NaiveDate">SubAssign&lt;Duration&gt;</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block"><li><a href="#impl-RefUnwindSafe-for-NaiveDate">RefUnwindSafe</a></li><li><a href="#impl-Send-for-NaiveDate">Send</a></li><li><a href="#impl-Sync-for-NaiveDate">Sync</a></li><li><a href="#impl-Unpin-for-NaiveDate">Unpin</a></li><li><a href="#impl-UnwindSafe-for-NaiveDate">UnwindSafe</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block"><li><a href="#impl-Any-for-NaiveDate">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-NaiveDate">Borrow&lt;T&gt;</a></li><li><a href="#impl-BorrowMut%3CT%3E-for-NaiveDate">BorrowMut&lt;T&gt;</a></li><li><a href="#impl-From%3CT%3E-for-NaiveDate">From&lt;T&gt;</a></li><li><a href="#impl-Into%3CU%3E-for-NaiveDate">Into&lt;U&gt;</a></li><li><a href="#impl-ToOwned-for-NaiveDate">ToOwned</a></li><li><a href="#impl-ToString-for-NaiveDate">ToString</a></li><li><a href="#impl-TryFrom%3CU%3E-for-NaiveDate">TryFrom&lt;U&gt;</a></li><li><a href="#impl-TryInto%3CU%3E-for-NaiveDate">TryInto&lt;U&gt;</a></li></ul></section><h2><a href="index.html">In chrono::naive</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 href="index.html">naive</a>::<wbr><a class="struct" href="#">NaiveDate</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/naive/date.rs.html#201-203">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><div class="item-decl"><pre class="rust struct"><code>pub struct NaiveDate { /* 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 calendar date without timezone.
Allows for every <a href="struct.NaiveDate.html#calendar-date">proleptic Gregorian date</a> from Jan 1, 262145 BCE to Dec 31, 262143 CE.
Also supports the conversion from ISO 8601 ordinal and week date.</p>
<h2 id="calendar-date"><a href="#calendar-date">Calendar Date</a></h2>
<p>The ISO 8601 <strong>calendar date</strong> follows the proleptic Gregorian calendar.
It is like a normal civil calendar but note some slight differences:</p>
<ul>
<li>
<p>Dates before the Gregorian calendar’s inception in 1582 are defined via the extrapolation.
Be careful, as historical dates are often noted in the Julian calendar and others
and the transition to Gregorian may differ across countries (as late as early 20C).</p>
<p>(Some example: Both Shakespeare from Britain and Cervantes from Spain seemingly died
on the same calendar date—April 23, 1616—but in the different calendar.
Britain used the Julian calendar at that time, so Shakespeare’s death is later.)</p>
</li>
<li>
<p>ISO 8601 calendars has the year 0, which is 1 BCE (a year before 1 CE).
If you need a typical BCE/BC and CE/AD notation for year numbers,
use the <a href="../trait.Datelike.html#method.year_ce"><code>Datelike::year_ce</code></a> method.</p>
</li>
</ul>
<h2 id="week-date"><a href="#week-date">Week Date</a></h2>
<p>The ISO 8601 <strong>week date</strong> is a triple of year number, week number
and <a href="../enum.Weekday.html">day of the week</a> with the following rules:</p>
<ul>
<li>
<p>A week consists of Monday through Sunday, and is always numbered within some year.
The week number ranges from 1 to 52 or 53 depending on the year.</p>
</li>
<li>
<p>The week 1 of given year is defined as the first week containing January 4 of that year,
or equivalently, the first week containing four or more days in that year.</p>
</li>
<li>
<p>The year number in the week date may <em>not</em> correspond to the actual Gregorian year.
For example, January 3, 2016 (Sunday) was on the last (53rd) week of 2015.</p>
</li>
</ul>
<p>Chrono’s date types default to the ISO 8601 <a href="#calendar-date">calendar date</a>,
but <a href="../trait.Datelike.html#tymethod.iso_week"><code>Datelike::iso_week</code></a> and
<a href="../trait.Datelike.html#tymethod.weekday"><code>Datelike::weekday</code></a> methods
can be used to get the corresponding week date.</p>
<h2 id="ordinal-date"><a href="#ordinal-date">Ordinal Date</a></h2>
<p>The ISO 8601 <strong>ordinal date</strong> is a pair of year number and day of the year (“ordinal”).
The ordinal number ranges from 1 to 365 or 366 depending on the year.
The year number is the same as that of the <a href="#calendar-date">calendar date</a>.</p>
<p>This is currently the internal format of Chrono’s date types.</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-NaiveDate" class="impl has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#250-1358">source</a><a href="#impl-NaiveDate" class="anchor"></a><h3 class="code-header">impl <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from_ymd" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#291-293">source</a><h4 class="code-header">pub fn <a href="#method.from_ymd" class="fnname">from_ymd</a>(year: i32, month: u32, day: u32) -&gt; <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h4></section><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated since 0.4.23: use <code>from_ymd_opt()</code> instead</span></div></span></summary><div class="docblock"><p>Makes a new <code>NaiveDate</code> from the <a href="#calendar-date">calendar date</a>
(year, month and day).</p>
<p>Panics on the out-of-range date, invalid month and/or day.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from_ymd_opt" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#315-318">source</a><h4 class="code-header">pub fn <a href="#method.from_ymd_opt" class="fnname">from_ymd_opt</a>(year: i32, month: u32, day: u32) -&gt; Option&lt;<a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a>&gt;</h4></section></summary><div class="docblock"><p>Makes a new <code>NaiveDate</code> from the <a href="#calendar-date">calendar date</a>
(year, month and day).</p>
<p>Returns <code>None</code> on the out-of-range date, invalid month and/or day.</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::NaiveDate;
<span class="kw">let </span>from_ymd_opt = NaiveDate::from_ymd_opt;
<span class="macro">assert!</span>(from_ymd_opt(<span class="number">2015</span>, <span class="number">3</span>, <span class="number">14</span>).is_some());
<span class="macro">assert!</span>(from_ymd_opt(<span class="number">2015</span>, <span class="number">0</span>, <span class="number">14</span>).is_none());
<span class="macro">assert!</span>(from_ymd_opt(<span class="number">2015</span>, <span class="number">2</span>, <span class="number">29</span>).is_none());
<span class="macro">assert!</span>(from_ymd_opt(-<span class="number">4</span>, <span class="number">2</span>, <span class="number">29</span>).is_some()); <span class="comment">// 5 BCE is a leap year
</span><span class="macro">assert!</span>(from_ymd_opt(<span class="number">400000</span>, <span class="number">1</span>, <span class="number">1</span>).is_none());
<span class="macro">assert!</span>(from_ymd_opt(-<span class="number">400000</span>, <span class="number">1</span>, <span class="number">1</span>).is_none());</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from_yo" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#326-328">source</a><h4 class="code-header">pub fn <a href="#method.from_yo" class="fnname">from_yo</a>(year: i32, ordinal: u32) -&gt; <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h4></section><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated since 0.4.23: use <code>from_yo_opt()</code> instead</span></div></span></summary><div class="docblock"><p>Makes a new <code>NaiveDate</code> from the <a href="#ordinal-date">ordinal date</a>
(year and day of the year).</p>
<p>Panics on the out-of-range date and/or invalid day of year.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from_yo_opt" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#351-354">source</a><h4 class="code-header">pub fn <a href="#method.from_yo_opt" class="fnname">from_yo_opt</a>(year: i32, ordinal: u32) -&gt; Option&lt;<a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a>&gt;</h4></section></summary><div class="docblock"><p>Makes a new <code>NaiveDate</code> from the <a href="#ordinal-date">ordinal date</a>
(year and day of the year).</p>
<p>Returns <code>None</code> on the out-of-range date and/or invalid day of year.</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::NaiveDate;
<span class="kw">let </span>from_yo_opt = NaiveDate::from_yo_opt;
<span class="macro">assert!</span>(from_yo_opt(<span class="number">2015</span>, <span class="number">100</span>).is_some());
<span class="macro">assert!</span>(from_yo_opt(<span class="number">2015</span>, <span class="number">0</span>).is_none());
<span class="macro">assert!</span>(from_yo_opt(<span class="number">2015</span>, <span class="number">365</span>).is_some());
<span class="macro">assert!</span>(from_yo_opt(<span class="number">2015</span>, <span class="number">366</span>).is_none());
<span class="macro">assert!</span>(from_yo_opt(-<span class="number">4</span>, <span class="number">366</span>).is_some()); <span class="comment">// 5 BCE is a leap year
</span><span class="macro">assert!</span>(from_yo_opt(<span class="number">400000</span>, <span class="number">1</span>).is_none());
<span class="macro">assert!</span>(from_yo_opt(-<span class="number">400000</span>, <span class="number">1</span>).is_none());</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from_isoywd" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#363-365">source</a><h4 class="code-header">pub fn <a href="#method.from_isoywd" class="fnname">from_isoywd</a>(year: i32, week: u32, weekday: <a class="enum" href="../enum.Weekday.html" title="enum chrono::Weekday">Weekday</a>) -&gt; <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h4></section><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated since 0.4.23: use <code>from_isoywd_opt()</code> instead</span></div></span></summary><div class="docblock"><p>Makes a new <code>NaiveDate</code> from the <a href="#week-date">ISO week date</a>
(year, week number and day of the week).
The resulting <code>NaiveDate</code> may have a different year from the input year.</p>
<p>Panics on the out-of-range date and/or invalid week number.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from_isoywd_opt" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#412-442">source</a><h4 class="code-header">pub fn <a href="#method.from_isoywd_opt" class="fnname">from_isoywd_opt</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;year: i32,<br>&nbsp;&nbsp;&nbsp;&nbsp;week: u32,<br>&nbsp;&nbsp;&nbsp;&nbsp;weekday: <a class="enum" href="../enum.Weekday.html" title="enum chrono::Weekday">Weekday</a><br>) -&gt; Option&lt;<a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a>&gt;</h4></section></summary><div class="docblock"><p>Makes a new <code>NaiveDate</code> from the <a href="#week-date">ISO week date</a>
(year, week number and day of the week).
The resulting <code>NaiveDate</code> may have a different year from the input year.</p>
<p>Returns <code>None</code> on the out-of-range date and/or invalid week number.</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::{NaiveDate, Weekday};
<span class="kw">let </span>from_ymd = |y, m, d| NaiveDate::from_ymd_opt(y, m, d).unwrap();
<span class="kw">let </span>from_isoywd_opt = NaiveDate::from_isoywd_opt;
<span class="macro">assert_eq!</span>(from_isoywd_opt(<span class="number">2015</span>, <span class="number">0</span>, Weekday::Sun), <span class="prelude-val">None</span>);
<span class="macro">assert_eq!</span>(from_isoywd_opt(<span class="number">2015</span>, <span class="number">10</span>, Weekday::Sun), <span class="prelude-val">Some</span>(from_ymd(<span class="number">2015</span>, <span class="number">3</span>, <span class="number">8</span>)));
<span class="macro">assert_eq!</span>(from_isoywd_opt(<span class="number">2015</span>, <span class="number">30</span>, Weekday::Mon), <span class="prelude-val">Some</span>(from_ymd(<span class="number">2015</span>, <span class="number">7</span>, <span class="number">20</span>)));
<span class="macro">assert_eq!</span>(from_isoywd_opt(<span class="number">2015</span>, <span class="number">60</span>, Weekday::Mon), <span class="prelude-val">None</span>);
<span class="macro">assert_eq!</span>(from_isoywd_opt(<span class="number">400000</span>, <span class="number">10</span>, Weekday::Fri), <span class="prelude-val">None</span>);
<span class="macro">assert_eq!</span>(from_isoywd_opt(-<span class="number">400000</span>, <span class="number">10</span>, Weekday::Sat), <span class="prelude-val">None</span>);</code></pre></div>
<p>The year number of ISO week date may differ from that of the calendar date.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="comment">// Mo Tu We Th Fr Sa Su
// 2014-W52 22 23 24 25 26 27 28 has 4+ days of new year,
// 2015-W01 29 30 31 1 2 3 4 &lt;- so this is the first week
</span><span class="macro">assert_eq!</span>(from_isoywd_opt(<span class="number">2014</span>, <span class="number">52</span>, Weekday::Sun), <span class="prelude-val">Some</span>(from_ymd(<span class="number">2014</span>, <span class="number">12</span>, <span class="number">28</span>)));
<span class="macro">assert_eq!</span>(from_isoywd_opt(<span class="number">2014</span>, <span class="number">53</span>, Weekday::Mon), <span class="prelude-val">None</span>);
<span class="macro">assert_eq!</span>(from_isoywd_opt(<span class="number">2015</span>, <span class="number">1</span>, Weekday::Mon), <span class="prelude-val">Some</span>(from_ymd(<span class="number">2014</span>, <span class="number">12</span>, <span class="number">29</span>)));
<span class="comment">// 2015-W52 21 22 23 24 25 26 27 has 4+ days of old year,
// 2015-W53 28 29 30 31 1 2 3 &lt;- so this is the last week
// 2016-W01 4 5 6 7 8 9 10
</span><span class="macro">assert_eq!</span>(from_isoywd_opt(<span class="number">2015</span>, <span class="number">52</span>, Weekday::Sun), <span class="prelude-val">Some</span>(from_ymd(<span class="number">2015</span>, <span class="number">12</span>, <span class="number">27</span>)));
<span class="macro">assert_eq!</span>(from_isoywd_opt(<span class="number">2015</span>, <span class="number">53</span>, Weekday::Sun), <span class="prelude-val">Some</span>(from_ymd(<span class="number">2016</span>, <span class="number">1</span>, <span class="number">3</span>)));
<span class="macro">assert_eq!</span>(from_isoywd_opt(<span class="number">2015</span>, <span class="number">54</span>, Weekday::Mon), <span class="prelude-val">None</span>);
<span class="macro">assert_eq!</span>(from_isoywd_opt(<span class="number">2016</span>, <span class="number">1</span>, Weekday::Mon), <span class="prelude-val">Some</span>(from_ymd(<span class="number">2016</span>, <span class="number">1</span>, <span class="number">4</span>)));</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from_num_days_from_ce" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#451-453">source</a><h4 class="code-header">pub fn <a href="#method.from_num_days_from_ce" class="fnname">from_num_days_from_ce</a>(days: i32) -&gt; <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h4></section><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated since 0.4.23: use <code>from_num_days_from_ce_opt()</code> instead</span></div></span></summary><div class="docblock"><p>Makes a new <code>NaiveDate</code> from a day’s number in the proleptic Gregorian calendar, with
January 1, 1 being day 1.</p>
<p>Panics if the date is out of range.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from_num_days_from_ce_opt" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#476-482">source</a><h4 class="code-header">pub fn <a href="#method.from_num_days_from_ce_opt" class="fnname">from_num_days_from_ce_opt</a>(days: i32) -&gt; Option&lt;<a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a>&gt;</h4></section></summary><div class="docblock"><p>Makes a new <code>NaiveDate</code> from a day’s number in the proleptic Gregorian calendar, with
January 1, 1 being day 1.</p>
<p>Returns <code>None</code> if the date is out of range.</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::NaiveDate;
<span class="kw">let </span>from_ndays_opt = NaiveDate::from_num_days_from_ce_opt;
<span class="kw">let </span>from_ymd = |y, m, d| NaiveDate::from_ymd_opt(y, m, d).unwrap();
<span class="macro">assert_eq!</span>(from_ndays_opt(<span class="number">730_000</span>), <span class="prelude-val">Some</span>(from_ymd(<span class="number">1999</span>, <span class="number">9</span>, <span class="number">3</span>)));
<span class="macro">assert_eq!</span>(from_ndays_opt(<span class="number">1</span>), <span class="prelude-val">Some</span>(from_ymd(<span class="number">1</span>, <span class="number">1</span>, <span class="number">1</span>)));
<span class="macro">assert_eq!</span>(from_ndays_opt(<span class="number">0</span>), <span class="prelude-val">Some</span>(from_ymd(<span class="number">0</span>, <span class="number">12</span>, <span class="number">31</span>)));
<span class="macro">assert_eq!</span>(from_ndays_opt(-<span class="number">1</span>), <span class="prelude-val">Some</span>(from_ymd(<span class="number">0</span>, <span class="number">12</span>, <span class="number">30</span>)));
<span class="macro">assert_eq!</span>(from_ndays_opt(<span class="number">100_000_000</span>), <span class="prelude-val">None</span>);
<span class="macro">assert_eq!</span>(from_ndays_opt(-<span class="number">100_000_000</span>), <span class="prelude-val">None</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from_weekday_of_month" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#496-498">source</a><h4 class="code-header">pub fn <a href="#method.from_weekday_of_month" class="fnname">from_weekday_of_month</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;year: i32,<br>&nbsp;&nbsp;&nbsp;&nbsp;month: u32,<br>&nbsp;&nbsp;&nbsp;&nbsp;weekday: <a class="enum" href="../enum.Weekday.html" title="enum chrono::Weekday">Weekday</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;n: u8<br>) -&gt; <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h4></section><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated since 0.4.23: use <code>from_weekday_of_month_opt()</code> instead</span></div></span></summary><div class="docblock"><p>Makes a new <code>NaiveDate</code> by counting the number of occurrences of a particular day-of-week
since the beginning of the given month. For instance, if you want the 2nd Friday of March
2017, you would use <code>NaiveDate::from_weekday_of_month(2017, 3, Weekday::Fri, 2)</code>.</p>
<h5 id="panics"><a href="#panics">Panics</a></h5>
<p>The resulting <code>NaiveDate</code> is guaranteed to be in <code>month</code>. If <code>n</code> is larger than the number
of <code>weekday</code> in <code>month</code> (eg. the 6th Friday of March 2017) then this function will panic.</p>
<p><code>n</code> is 1-indexed. Passing <code>n=0</code> will cause a panic.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from_weekday_of_month_opt" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#513-526">source</a><h4 class="code-header">pub fn <a href="#method.from_weekday_of_month_opt" class="fnname">from_weekday_of_month_opt</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;year: i32,<br>&nbsp;&nbsp;&nbsp;&nbsp;month: u32,<br>&nbsp;&nbsp;&nbsp;&nbsp;weekday: <a class="enum" href="../enum.Weekday.html" title="enum chrono::Weekday">Weekday</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;n: u8<br>) -&gt; Option&lt;<a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a>&gt;</h4></section></summary><div class="docblock"><p>Makes a new <code>NaiveDate</code> by counting the number of occurrences of a particular day-of-week
since the beginning of the given month. For instance, if you want the 2nd Friday of March
2017, you would use <code>NaiveDate::from_weekday_of_month(2017, 3, Weekday::Fri, 2)</code>. <code>n</code> is 1-indexed.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{NaiveDate, Weekday};
<span class="macro">assert_eq!</span>(NaiveDate::from_weekday_of_month_opt(<span class="number">2017</span>, <span class="number">3</span>, Weekday::Fri, <span class="number">2</span>),
NaiveDate::from_ymd_opt(<span class="number">2017</span>, <span class="number">3</span>, <span class="number">10</span>))</code></pre></div>
<p>Returns <code>None</code> if <code>n</code> out-of-range; ie. if <code>n</code> is larger than the number of <code>weekday</code> in
<code>month</code> (eg. the 6th Friday of March 2017), or if <code>n == 0</code>.</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/naive/date.rs.html#570-574">source</a><h4 class="code-header">pub fn <a href="#method.parse_from_str" class="fnname">parse_from_str</a>(s: &amp;str, fmt: &amp;str) -&gt; <a class="type" href="../format/type.ParseResult.html" title="type chrono::format::ParseResult">ParseResult</a>&lt;<a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a>&gt;</h4></section></summary><div class="docblock"><p>Parses a string with the specified format string and returns a new <code>NaiveDate</code>.
See the <a href="../format/strftime/index.html"><code>format::strftime</code> module</a>
on the supported escape sequences.</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::NaiveDate;
<span class="kw">let </span>parse_from_str = NaiveDate::parse_from_str;
<span class="macro">assert_eq!</span>(parse_from_str(<span class="string">&quot;2015-09-05&quot;</span>, <span class="string">&quot;%Y-%m-%d&quot;</span>),
<span class="prelude-val">Ok</span>(NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">5</span>).unwrap()));
<span class="macro">assert_eq!</span>(parse_from_str(<span class="string">&quot;5sep2015&quot;</span>, <span class="string">&quot;%d%b%Y&quot;</span>),
<span class="prelude-val">Ok</span>(NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">5</span>).unwrap()));</code></pre></div>
<p>Time and offset is ignored for the purpose of parsing.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(parse_from_str(<span class="string">&quot;2014-5-17T12:34:56+09:30&quot;</span>, <span class="string">&quot;%Y-%m-%dT%H:%M:%S%z&quot;</span>),
<span class="prelude-val">Ok</span>(NaiveDate::from_ymd_opt(<span class="number">2014</span>, <span class="number">5</span>, <span class="number">17</span>).unwrap()));</code></pre></div>
<p>Out-of-bound dates or insufficient fields are errors.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert!</span>(parse_from_str(<span class="string">&quot;2015/9&quot;</span>, <span class="string">&quot;%Y/%m&quot;</span>).is_err());
<span class="macro">assert!</span>(parse_from_str(<span class="string">&quot;2015/9/31&quot;</span>, <span class="string">&quot;%Y/%m/%d&quot;</span>).is_err());</code></pre></div>
<p>All parsed fields should be consistent to each other, otherwise it’s an error.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert!</span>(parse_from_str(<span class="string">&quot;Sat, 09 Aug 2013&quot;</span>, <span class="string">&quot;%a, %d %b %Y&quot;</span>).is_err());</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/naive/date.rs.html#592-596">source</a><h4 class="code-header">pub fn <a href="#method.parse_and_remainder" class="fnname">parse_and_remainder</a>&lt;'a&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;s: &amp;'a str,<br>&nbsp;&nbsp;&nbsp;&nbsp;fmt: &amp;str<br>) -&gt; <a class="type" href="../format/type.ParseResult.html" title="type chrono::format::ParseResult">ParseResult</a>&lt;(<a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a>, &amp;'a str)&gt;</h4></section></summary><div class="docblock"><p>Parses a string from a user-specified format into a new <code>NaiveDate</code> value, and a slice with
the remaining portion of the string.
See the <a href="../format/strftime/index.html"><code>format::strftime</code> module</a>
on the supported escape sequences.</p>
<p>Similar to <a href="#method.parse_from_str"><code>parse_from_str</code></a>.</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">let </span>(date, remainder) = NaiveDate::parse_and_remainder(
<span class="string">&quot;2015-02-18 trailing text&quot;</span>, <span class="string">&quot;%Y-%m-%d&quot;</span>).unwrap();
<span class="macro">assert_eq!</span>(date, NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">2</span>, <span class="number">18</span>).unwrap());
<span class="macro">assert_eq!</span>(remainder, <span class="string">&quot; trailing text&quot;</span>);</code></pre></div>
</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/naive/date.rs.html#616-625">source</a><h4 class="code-header">pub fn <a href="#method.checked_add_months" class="fnname">checked_add_months</a>(self, months: <a class="struct" href="../struct.Months.html" title="struct chrono::Months">Months</a>) -&gt; Option&lt;Self&gt;</h4></section></summary><div class="docblock"><p>Add a duration in <a href="../struct.Months.html" title="Months"><code>Months</code></a> to the date</p>
<p>If the day would be out of range for the resulting month, use the last day for that month.</p>
<p>Returns <code>None</code> if the resulting date would be out of range.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(
NaiveDate::from_ymd_opt(<span class="number">2022</span>, <span class="number">2</span>, <span class="number">20</span>).unwrap().checked_add_months(Months::new(<span class="number">6</span>)),
<span class="prelude-val">Some</span>(NaiveDate::from_ymd_opt(<span class="number">2022</span>, <span class="number">8</span>, <span class="number">20</span>).unwrap())
);
<span class="macro">assert_eq!</span>(
NaiveDate::from_ymd_opt(<span class="number">2022</span>, <span class="number">7</span>, <span class="number">31</span>).unwrap().checked_add_months(Months::new(<span class="number">2</span>)),
<span class="prelude-val">Some</span>(NaiveDate::from_ymd_opt(<span class="number">2022</span>, <span class="number">9</span>, <span class="number">30</span>).unwrap())
);</code></pre></div>
</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/naive/date.rs.html#647-657">source</a><h4 class="code-header">pub fn <a href="#method.checked_sub_months" class="fnname">checked_sub_months</a>(self, months: <a class="struct" href="../struct.Months.html" title="struct chrono::Months">Months</a>) -&gt; Option&lt;Self&gt;</h4></section></summary><div class="docblock"><p>Subtract a duration in <a href="../struct.Months.html" title="Months"><code>Months</code></a> from the date</p>
<p>If the day would be out of range for the resulting month, use the last day for that month.</p>
<p>Returns <code>None</code> if the resulting date would be out of range.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(
NaiveDate::from_ymd_opt(<span class="number">2022</span>, <span class="number">2</span>, <span class="number">20</span>).unwrap().checked_sub_months(Months::new(<span class="number">6</span>)),
<span class="prelude-val">Some</span>(NaiveDate::from_ymd_opt(<span class="number">2021</span>, <span class="number">8</span>, <span class="number">20</span>).unwrap())
);
<span class="macro">assert_eq!</span>(
NaiveDate::from_ymd_opt(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>).unwrap()
.checked_sub_months(Months::new(core::i32::MAX <span class="kw">as </span>u32 + <span class="number">1</span>)),
<span class="prelude-val">None
</span>);</code></pre></div>
</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/naive/date.rs.html#721-727">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="struct.Days.html" title="struct chrono::naive::Days">Days</a>) -&gt; Option&lt;Self&gt;</h4></section></summary><div class="docblock"><p>Add a duration in <a href="struct.Days.html" title="Days"><code>Days</code></a> to the date</p>
<p>Returns <code>None</code> if the resulting date would be out of range.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(
NaiveDate::from_ymd_opt(<span class="number">2022</span>, <span class="number">2</span>, <span class="number">20</span>).unwrap().checked_add_days(Days::new(<span class="number">9</span>)),
<span class="prelude-val">Some</span>(NaiveDate::from_ymd_opt(<span class="number">2022</span>, <span class="number">3</span>, <span class="number">1</span>).unwrap())
);
<span class="macro">assert_eq!</span>(
NaiveDate::from_ymd_opt(<span class="number">2022</span>, <span class="number">7</span>, <span class="number">31</span>).unwrap().checked_add_days(Days::new(<span class="number">2</span>)),
<span class="prelude-val">Some</span>(NaiveDate::from_ymd_opt(<span class="number">2022</span>, <span class="number">8</span>, <span class="number">2</span>).unwrap())
);
<span class="macro">assert_eq!</span>(
NaiveDate::from_ymd_opt(<span class="number">2022</span>, <span class="number">7</span>, <span class="number">31</span>).unwrap().checked_add_days(Days::new(<span class="number">1000000000000</span>)),
<span class="prelude-val">None
</span>);</code></pre></div>
</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/naive/date.rs.html#745-751">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="struct.Days.html" title="struct chrono::naive::Days">Days</a>) -&gt; Option&lt;Self&gt;</h4></section></summary><div class="docblock"><p>Subtract a duration in <a href="struct.Days.html" title="Days"><code>Days</code></a> from the date</p>
<p>Returns <code>None</code> if the resulting date would be out of range.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(
NaiveDate::from_ymd_opt(<span class="number">2022</span>, <span class="number">2</span>, <span class="number">20</span>).unwrap().checked_sub_days(Days::new(<span class="number">6</span>)),
<span class="prelude-val">Some</span>(NaiveDate::from_ymd_opt(<span class="number">2022</span>, <span class="number">2</span>, <span class="number">14</span>).unwrap())
);
<span class="macro">assert_eq!</span>(
NaiveDate::from_ymd_opt(<span class="number">2022</span>, <span class="number">2</span>, <span class="number">20</span>).unwrap().checked_sub_days(Days::new(<span class="number">1000000000000</span>)),
<span class="prelude-val">None
</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.and_time" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#777-779">source</a><h4 class="code-header">pub const fn <a href="#method.and_time" class="fnname">and_time</a>(&amp;self, time: <a class="struct" href="struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a>) -&gt; <a class="struct" href="struct.NaiveDateTime.html" title="struct chrono::naive::NaiveDateTime">NaiveDateTime</a></h4></section></summary><div class="docblock"><p>Makes a new <code>NaiveDateTime</code> from the current date and given <code>NaiveTime</code>.</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">use </span>chrono::{NaiveDate, NaiveTime, NaiveDateTime};
<span class="kw">let </span>d = NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">6</span>, <span class="number">3</span>).unwrap();
<span class="kw">let </span>t = NaiveTime::from_hms_milli_opt(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>, <span class="number">789</span>).unwrap();
<span class="kw">let </span>dt: NaiveDateTime = d.and_time(t);
<span class="macro">assert_eq!</span>(dt.date(), d);
<span class="macro">assert_eq!</span>(dt.time(), t);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.and_hms" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#790-792">source</a><h4 class="code-header">pub fn <a href="#method.and_hms" class="fnname">and_hms</a>(&amp;self, hour: u32, min: u32, sec: u32) -&gt; <a class="struct" href="struct.NaiveDateTime.html" title="struct chrono::naive::NaiveDateTime">NaiveDateTime</a></h4></section><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated since 0.4.23: use <code>and_hms_opt()</code> instead</span></div></span></summary><div class="docblock"><p>Makes a new <code>NaiveDateTime</code> from the current date, hour, minute and second.</p>
<p>No <a href="./struct.NaiveTime.html#leap-second-handling">leap second</a> is allowed here;
use <code>NaiveDate::and_hms_*</code> methods with a subsecond parameter instead.</p>
<p>Panics on invalid hour, minute and/or second.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.and_hms_opt" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#814-816">source</a><h4 class="code-header">pub fn <a href="#method.and_hms_opt" class="fnname">and_hms_opt</a>(&amp;self, hour: u32, min: u32, sec: u32) -&gt; Option&lt;<a class="struct" href="struct.NaiveDateTime.html" title="struct chrono::naive::NaiveDateTime">NaiveDateTime</a>&gt;</h4></section></summary><div class="docblock"><p>Makes a new <code>NaiveDateTime</code> from the current date, hour, minute and second.</p>
<p>No <a href="./struct.NaiveTime.html#leap-second-handling">leap second</a> is allowed here;
use <code>NaiveDate::and_hms_*_opt</code> methods with a subsecond parameter instead.</p>
<p>Returns <code>None</code> on invalid hour, minute and/or second.</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::NaiveDate;
<span class="kw">let </span>d = NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">6</span>, <span class="number">3</span>).unwrap();
<span class="macro">assert!</span>(d.and_hms_opt(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>).is_some());
<span class="macro">assert!</span>(d.and_hms_opt(<span class="number">12</span>, <span class="number">34</span>, <span class="number">60</span>).is_none()); <span class="comment">// use `and_hms_milli_opt` instead
</span><span class="macro">assert!</span>(d.and_hms_opt(<span class="number">12</span>, <span class="number">60</span>, <span class="number">56</span>).is_none());
<span class="macro">assert!</span>(d.and_hms_opt(<span class="number">24</span>, <span class="number">34</span>, <span class="number">56</span>).is_none());</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.and_hms_milli" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#827-829">source</a><h4 class="code-header">pub fn <a href="#method.and_hms_milli" class="fnname">and_hms_milli</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;hour: u32,<br>&nbsp;&nbsp;&nbsp;&nbsp;min: u32,<br>&nbsp;&nbsp;&nbsp;&nbsp;sec: u32,<br>&nbsp;&nbsp;&nbsp;&nbsp;milli: u32<br>) -&gt; <a class="struct" href="struct.NaiveDateTime.html" title="struct chrono::naive::NaiveDateTime">NaiveDateTime</a></h4></section><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated since 0.4.23: use <code>and_hms_milli_opt()</code> instead</span></div></span></summary><div class="docblock"><p>Makes a new <code>NaiveDateTime</code> from the current date, hour, minute, second and millisecond.</p>
<p>The millisecond part can exceed 1,000
in order to represent the <a href="./struct.NaiveTime.html#leap-second-handling">leap second</a>.</p>
<p>Panics on invalid hour, minute, second and/or millisecond.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.and_hms_milli_opt" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#853-861">source</a><h4 class="code-header">pub fn <a href="#method.and_hms_milli_opt" class="fnname">and_hms_milli_opt</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;hour: u32,<br>&nbsp;&nbsp;&nbsp;&nbsp;min: u32,<br>&nbsp;&nbsp;&nbsp;&nbsp;sec: u32,<br>&nbsp;&nbsp;&nbsp;&nbsp;milli: u32<br>) -&gt; Option&lt;<a class="struct" href="struct.NaiveDateTime.html" title="struct chrono::naive::NaiveDateTime">NaiveDateTime</a>&gt;</h4></section></summary><div class="docblock"><p>Makes a new <code>NaiveDateTime</code> from the current date, hour, minute, second and millisecond.</p>
<p>The millisecond part can exceed 1,000
in order to represent the <a href="./struct.NaiveTime.html#leap-second-handling">leap second</a>.</p>
<p>Returns <code>None</code> on invalid hour, minute, second and/or millisecond.</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::NaiveDate;
<span class="kw">let </span>d = NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">6</span>, <span class="number">3</span>).unwrap();
<span class="macro">assert!</span>(d.and_hms_milli_opt(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>, <span class="number">789</span>).is_some());
<span class="macro">assert!</span>(d.and_hms_milli_opt(<span class="number">12</span>, <span class="number">34</span>, <span class="number">59</span>, <span class="number">1_789</span>).is_some()); <span class="comment">// leap second
</span><span class="macro">assert!</span>(d.and_hms_milli_opt(<span class="number">12</span>, <span class="number">34</span>, <span class="number">59</span>, <span class="number">2_789</span>).is_none());
<span class="macro">assert!</span>(d.and_hms_milli_opt(<span class="number">12</span>, <span class="number">34</span>, <span class="number">60</span>, <span class="number">789</span>).is_none());
<span class="macro">assert!</span>(d.and_hms_milli_opt(<span class="number">12</span>, <span class="number">60</span>, <span class="number">56</span>, <span class="number">789</span>).is_none());
<span class="macro">assert!</span>(d.and_hms_milli_opt(<span class="number">24</span>, <span class="number">34</span>, <span class="number">56</span>, <span class="number">789</span>).is_none());</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.and_hms_micro" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#886-888">source</a><h4 class="code-header">pub fn <a href="#method.and_hms_micro" class="fnname">and_hms_micro</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;hour: u32,<br>&nbsp;&nbsp;&nbsp;&nbsp;min: u32,<br>&nbsp;&nbsp;&nbsp;&nbsp;sec: u32,<br>&nbsp;&nbsp;&nbsp;&nbsp;micro: u32<br>) -&gt; <a class="struct" href="struct.NaiveDateTime.html" title="struct chrono::naive::NaiveDateTime">NaiveDateTime</a></h4></section><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated since 0.4.23: use <code>and_hms_micro_opt()</code> instead</span></div></span></summary><div class="docblock"><p>Makes a new <code>NaiveDateTime</code> from the current date, hour, minute, second and microsecond.</p>
<p>The microsecond part can exceed 1,000,000
in order to represent the <a href="./struct.NaiveTime.html#leap-second-handling">leap second</a>.</p>
<p>Panics on invalid hour, minute, second and/or microsecond.</p>
<h5 id="example-9"><a href="#example-9">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{NaiveDate, NaiveDateTime, Datelike, Timelike, Weekday};
<span class="kw">let </span>d = NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">6</span>, <span class="number">3</span>).unwrap();
<span class="kw">let </span>dt: NaiveDateTime = d.and_hms_micro_opt(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>, <span class="number">789_012</span>).unwrap();
<span class="macro">assert_eq!</span>(dt.year(), <span class="number">2015</span>);
<span class="macro">assert_eq!</span>(dt.weekday(), Weekday::Wed);
<span class="macro">assert_eq!</span>(dt.second(), <span class="number">56</span>);
<span class="macro">assert_eq!</span>(dt.nanosecond(), <span class="number">789_012_000</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.and_hms_micro_opt" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#912-920">source</a><h4 class="code-header">pub fn <a href="#method.and_hms_micro_opt" class="fnname">and_hms_micro_opt</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;hour: u32,<br>&nbsp;&nbsp;&nbsp;&nbsp;min: u32,<br>&nbsp;&nbsp;&nbsp;&nbsp;sec: u32,<br>&nbsp;&nbsp;&nbsp;&nbsp;micro: u32<br>) -&gt; Option&lt;<a class="struct" href="struct.NaiveDateTime.html" title="struct chrono::naive::NaiveDateTime">NaiveDateTime</a>&gt;</h4></section></summary><div class="docblock"><p>Makes a new <code>NaiveDateTime</code> from the current date, hour, minute, second and microsecond.</p>
<p>The microsecond part can exceed 1,000,000
in order to represent the <a href="./struct.NaiveTime.html#leap-second-handling">leap second</a>.</p>
<p>Returns <code>None</code> on invalid hour, minute, second and/or microsecond.</p>
<h5 id="example-10"><a href="#example-10">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::NaiveDate;
<span class="kw">let </span>d = NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">6</span>, <span class="number">3</span>).unwrap();
<span class="macro">assert!</span>(d.and_hms_micro_opt(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>, <span class="number">789_012</span>).is_some());
<span class="macro">assert!</span>(d.and_hms_micro_opt(<span class="number">12</span>, <span class="number">34</span>, <span class="number">59</span>, <span class="number">1_789_012</span>).is_some()); <span class="comment">// leap second
</span><span class="macro">assert!</span>(d.and_hms_micro_opt(<span class="number">12</span>, <span class="number">34</span>, <span class="number">59</span>, <span class="number">2_789_012</span>).is_none());
<span class="macro">assert!</span>(d.and_hms_micro_opt(<span class="number">12</span>, <span class="number">34</span>, <span class="number">60</span>, <span class="number">789_012</span>).is_none());
<span class="macro">assert!</span>(d.and_hms_micro_opt(<span class="number">12</span>, <span class="number">60</span>, <span class="number">56</span>, <span class="number">789_012</span>).is_none());
<span class="macro">assert!</span>(d.and_hms_micro_opt(<span class="number">24</span>, <span class="number">34</span>, <span class="number">56</span>, <span class="number">789_012</span>).is_none());</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.and_hms_nano" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#931-933">source</a><h4 class="code-header">pub fn <a href="#method.and_hms_nano" class="fnname">and_hms_nano</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;hour: u32,<br>&nbsp;&nbsp;&nbsp;&nbsp;min: u32,<br>&nbsp;&nbsp;&nbsp;&nbsp;sec: u32,<br>&nbsp;&nbsp;&nbsp;&nbsp;nano: u32<br>) -&gt; <a class="struct" href="struct.NaiveDateTime.html" title="struct chrono::naive::NaiveDateTime">NaiveDateTime</a></h4></section><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated since 0.4.23: use <code>and_hms_nano_opt()</code> instead</span></div></span></summary><div class="docblock"><p>Makes a new <code>NaiveDateTime</code> from the current date, hour, minute, second and nanosecond.</p>
<p>The nanosecond part can exceed 1,000,000,000
in order to represent the <a href="./struct.NaiveTime.html#leap-second-handling">leap second</a>.</p>
<p>Panics on invalid hour, minute, second and/or nanosecond.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.and_hms_nano_opt" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#957-965">source</a><h4 class="code-header">pub fn <a href="#method.and_hms_nano_opt" class="fnname">and_hms_nano_opt</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;hour: u32,<br>&nbsp;&nbsp;&nbsp;&nbsp;min: u32,<br>&nbsp;&nbsp;&nbsp;&nbsp;sec: u32,<br>&nbsp;&nbsp;&nbsp;&nbsp;nano: u32<br>) -&gt; Option&lt;<a class="struct" href="struct.NaiveDateTime.html" title="struct chrono::naive::NaiveDateTime">NaiveDateTime</a>&gt;</h4></section></summary><div class="docblock"><p>Makes a new <code>NaiveDateTime</code> from the current date, hour, minute, second and nanosecond.</p>
<p>The nanosecond part can exceed 1,000,000,000
in order to represent the <a href="./struct.NaiveTime.html#leap-second-handling">leap second</a>.</p>
<p>Returns <code>None</code> on invalid hour, minute, second and/or nanosecond.</p>
<h5 id="example-11"><a href="#example-11">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::NaiveDate;
<span class="kw">let </span>d = NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">6</span>, <span class="number">3</span>).unwrap();
<span class="macro">assert!</span>(d.and_hms_nano_opt(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>, <span class="number">789_012_345</span>).is_some());
<span class="macro">assert!</span>(d.and_hms_nano_opt(<span class="number">12</span>, <span class="number">34</span>, <span class="number">59</span>, <span class="number">1_789_012_345</span>).is_some()); <span class="comment">// leap second
</span><span class="macro">assert!</span>(d.and_hms_nano_opt(<span class="number">12</span>, <span class="number">34</span>, <span class="number">59</span>, <span class="number">2_789_012_345</span>).is_none());
<span class="macro">assert!</span>(d.and_hms_nano_opt(<span class="number">12</span>, <span class="number">34</span>, <span class="number">60</span>, <span class="number">789_012_345</span>).is_none());
<span class="macro">assert!</span>(d.and_hms_nano_opt(<span class="number">12</span>, <span class="number">60</span>, <span class="number">56</span>, <span class="number">789_012_345</span>).is_none());
<span class="macro">assert!</span>(d.and_hms_nano_opt(<span class="number">24</span>, <span class="number">34</span>, <span class="number">56</span>, <span class="number">789_012_345</span>).is_none());</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.succ" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#1002-1004">source</a><h4 class="code-header">pub fn <a href="#method.succ" class="fnname">succ</a>(&amp;self) -&gt; <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h4></section><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated since 0.4.23: use <code>succ_opt()</code> instead</span></div></span></summary><div class="docblock"><p>Makes a new <code>NaiveDate</code> for the next calendar date.</p>
<p>Panics when <code>self</code> is the last representable date.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.succ_opt" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#1021-1026">source</a><h4 class="code-header">pub fn <a href="#method.succ_opt" class="fnname">succ_opt</a>(&amp;self) -&gt; Option&lt;<a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a>&gt;</h4></section></summary><div class="docblock"><p>Makes a new <code>NaiveDate</code> for the next calendar date.</p>
<p>Returns <code>None</code> when <code>self</code> is the last representable date.</p>
<h5 id="example-12"><a href="#example-12">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::NaiveDate;
<span class="macro">assert_eq!</span>(NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">6</span>, <span class="number">3</span>).unwrap().succ_opt(),
<span class="prelude-val">Some</span>(NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">6</span>, <span class="number">4</span>).unwrap()));
<span class="macro">assert_eq!</span>(NaiveDate::MAX.succ_opt(), <span class="prelude-val">None</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.pred" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#1034-1036">source</a><h4 class="code-header">pub fn <a href="#method.pred" class="fnname">pred</a>(&amp;self) -&gt; <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h4></section><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated since 0.4.23: use <code>pred_opt()</code> instead</span></div></span></summary><div class="docblock"><p>Makes a new <code>NaiveDate</code> for the previous calendar date.</p>
<p>Panics when <code>self</code> is the first representable date.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.pred_opt" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#1053-1058">source</a><h4 class="code-header">pub fn <a href="#method.pred_opt" class="fnname">pred_opt</a>(&amp;self) -&gt; Option&lt;<a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a>&gt;</h4></section></summary><div class="docblock"><p>Makes a new <code>NaiveDate</code> for the previous calendar date.</p>
<p>Returns <code>None</code> when <code>self</code> is the first representable date.</p>
<h5 id="example-13"><a href="#example-13">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::NaiveDate;
<span class="macro">assert_eq!</span>(NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">6</span>, <span class="number">3</span>).unwrap().pred_opt(),
<span class="prelude-val">Some</span>(NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">6</span>, <span class="number">2</span>).unwrap()));
<span class="macro">assert_eq!</span>(NaiveDate::MIN.pred_opt(), <span class="prelude-val">None</span>);</code></pre></div>
</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/naive/date.rs.html#1079-1090">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>) -&gt; Option&lt;<a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a>&gt;</h4></section></summary><div class="docblock"><p>Adds the <code>days</code> part of given <code>Duration</code> to the current date.</p>
<p>Returns <code>None</code> when it will result in overflow.</p>
<h5 id="example-14"><a href="#example-14">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{Duration, NaiveDate};
<span class="kw">let </span>d = NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">5</span>).unwrap();
<span class="macro">assert_eq!</span>(d.checked_add_signed(Duration::days(<span class="number">40</span>)),
<span class="prelude-val">Some</span>(NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">10</span>, <span class="number">15</span>).unwrap()));
<span class="macro">assert_eq!</span>(d.checked_add_signed(Duration::days(-<span class="number">40</span>)),
<span class="prelude-val">Some</span>(NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">7</span>, <span class="number">27</span>).unwrap()));
<span class="macro">assert_eq!</span>(d.checked_add_signed(Duration::days(<span class="number">1_000_000_000</span>)), <span class="prelude-val">None</span>);
<span class="macro">assert_eq!</span>(d.checked_add_signed(Duration::days(-<span class="number">1_000_000_000</span>)), <span class="prelude-val">None</span>);
<span class="macro">assert_eq!</span>(NaiveDate::MAX.checked_add_signed(Duration::days(<span class="number">1</span>)), <span class="prelude-val">None</span>);</code></pre></div>
</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/naive/date.rs.html#1111-1122">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>) -&gt; Option&lt;<a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a>&gt;</h4></section></summary><div class="docblock"><p>Subtracts the <code>days</code> part of given <code>Duration</code> from the current date.</p>
<p>Returns <code>None</code> when it will result in overflow.</p>
<h5 id="example-15"><a href="#example-15">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{Duration, NaiveDate};
<span class="kw">let </span>d = NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">5</span>).unwrap();
<span class="macro">assert_eq!</span>(d.checked_sub_signed(Duration::days(<span class="number">40</span>)),
<span class="prelude-val">Some</span>(NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">7</span>, <span class="number">27</span>).unwrap()));
<span class="macro">assert_eq!</span>(d.checked_sub_signed(Duration::days(-<span class="number">40</span>)),
<span class="prelude-val">Some</span>(NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">10</span>, <span class="number">15</span>).unwrap()));
<span class="macro">assert_eq!</span>(d.checked_sub_signed(Duration::days(<span class="number">1_000_000_000</span>)), <span class="prelude-val">None</span>);
<span class="macro">assert_eq!</span>(d.checked_sub_signed(Duration::days(-<span class="number">1_000_000_000</span>)), <span class="prelude-val">None</span>);
<span class="macro">assert_eq!</span>(NaiveDate::MIN.checked_sub_signed(Duration::days(<span class="number">1</span>)), <span class="prelude-val">None</span>);</code></pre></div>
</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/naive/date.rs.html#1147-1157">source</a><h4 class="code-header">pub fn <a href="#method.signed_duration_since" class="fnname">signed_duration_since</a>(self, rhs: <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a>) -&gt; <a class="struct" href="../struct.Duration.html" title="struct chrono::Duration">OldDuration</a></h4></section></summary><div class="docblock"><p>Subtracts another <code>NaiveDate</code> from the current date.
Returns a <code>Duration</code> of integral numbers.</p>
<p>This does not overflow or underflow at all,
as all possible output fits in the range of <code>Duration</code>.</p>
<h5 id="example-16"><a href="#example-16">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{Duration, NaiveDate};
<span class="kw">let </span>from_ymd = |y, m, d| NaiveDate::from_ymd_opt(y, m, d).unwrap();
<span class="kw">let </span>since = NaiveDate::signed_duration_since;
<span class="macro">assert_eq!</span>(since(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>), from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>)), Duration::zero());
<span class="macro">assert_eq!</span>(since(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>), from_ymd(<span class="number">2013</span>, <span class="number">12</span>, <span class="number">31</span>)), Duration::days(<span class="number">1</span>));
<span class="macro">assert_eq!</span>(since(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>), from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">2</span>)), Duration::days(-<span class="number">1</span>));
<span class="macro">assert_eq!</span>(since(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>), from_ymd(<span class="number">2013</span>, <span class="number">9</span>, <span class="number">23</span>)), Duration::days(<span class="number">100</span>));
<span class="macro">assert_eq!</span>(since(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>), from_ymd(<span class="number">2013</span>, <span class="number">1</span>, <span class="number">1</span>)), Duration::days(<span class="number">365</span>));
<span class="macro">assert_eq!</span>(since(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>), from_ymd(<span class="number">2010</span>, <span class="number">1</span>, <span class="number">1</span>)), Duration::days(<span class="number">365</span><span class="kw-2">*</span><span class="number">4 </span>+ <span class="number">1</span>));
<span class="macro">assert_eq!</span>(since(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>), from_ymd(<span class="number">1614</span>, <span class="number">1</span>, <span class="number">1</span>)), Duration::days(<span class="number">365</span><span class="kw-2">*</span><span class="number">400 </span>+ <span class="number">97</span>));</code></pre></div>
</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/naive/date.rs.html#1161-1171">source</a><h4 class="code-header">pub fn <a href="#method.years_since" class="fnname">years_since</a>(&amp;self, base: Self) -&gt; Option&lt;u32&gt;</h4></section></summary><div class="docblock"><p>Returns the number of whole years from the given <code>base</code> until <code>self</code>.</p>
</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/naive/date.rs.html#1204-1210">source</a><h4 class="code-header">pub fn <a href="#method.format_with_items" class="fnname">format_with_items</a>&lt;'a, I, B&gt;(&amp;self, items: I) -&gt; <a class="struct" href="../format/struct.DelayedFormat.html" title="struct chrono::format::DelayedFormat">DelayedFormat</a>&lt;I&gt;<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;I: Iterator&lt;Item = B&gt; + Clone,<br>&nbsp;&nbsp;&nbsp;&nbsp;B: Borrow&lt;<a class="enum" href="../format/enum.Item.html" title="enum chrono::format::Item">Item</a>&lt;'a&gt;&gt;,</span></h4></section></summary><div class="docblock"><p>Formats the date with the specified formatting items.
Otherwise it is the same as the ordinary <code>format</code> method.</p>
<p>The <code>Iterator</code> of items should be <code>Clone</code>able,
since the resulting <code>DelayedFormat</code> value may be formatted multiple times.</p>
<h5 id="example-17"><a href="#example-17">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::NaiveDate;
<span class="kw">use </span>chrono::format::strftime::StrftimeItems;
<span class="kw">let </span>fmt = StrftimeItems::new(<span class="string">&quot;%Y-%m-%d&quot;</span>);
<span class="kw">let </span>d = NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">5</span>).unwrap();
<span class="macro">assert_eq!</span>(d.format_with_items(fmt.clone()).to_string(), <span class="string">&quot;2015-09-05&quot;</span>);
<span class="macro">assert_eq!</span>(d.format(<span class="string">&quot;%Y-%m-%d&quot;</span>).to_string(), <span class="string">&quot;2015-09-05&quot;</span>);</code></pre></div>
<p>The resulting <code>DelayedFormat</code> can be formatted directly via the <code>Display</code> trait.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(<span class="macro">format!</span>(<span class="string">&quot;{}&quot;</span>, d.format_with_items(fmt)), <span class="string">&quot;2015-09-05&quot;</span>);</code></pre></div>
</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/naive/date.rs.html#1248-1250">source</a><h4 class="code-header">pub fn <a href="#method.format" class="fnname">format</a>&lt;'a&gt;(&amp;self, fmt: &amp;'a str) -&gt; <a class="struct" href="../format/struct.DelayedFormat.html" title="struct chrono::format::DelayedFormat">DelayedFormat</a>&lt;<a class="struct" href="../format/strftime/struct.StrftimeItems.html" title="struct chrono::format::strftime::StrftimeItems">StrftimeItems</a>&lt;'a&gt;&gt;</h4></section></summary><div class="docblock"><p>Formats the date with the specified format string.
See the <a href="../format/strftime/index.html"><code>format::strftime</code> module</a>
on the supported escape sequences.</p>
<p>This returns a <code>DelayedFormat</code>,
which gets converted to a string only when actual formatting happens.
You may use the <code>to_string</code> method to get a <code>String</code>,
or just feed it into <code>print!</code> and other formatting macros.
(In this way it avoids the redundant memory allocation.)</p>
<p>A wrong format string does <em>not</em> issue an error immediately.
Rather, converting or formatting the <code>DelayedFormat</code> fails.
You are recommended to immediately use <code>DelayedFormat</code> for this reason.</p>
<h5 id="example-18"><a href="#example-18">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::NaiveDate;
<span class="kw">let </span>d = NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">5</span>).unwrap();
<span class="macro">assert_eq!</span>(d.format(<span class="string">&quot;%Y-%m-%d&quot;</span>).to_string(), <span class="string">&quot;2015-09-05&quot;</span>);
<span class="macro">assert_eq!</span>(d.format(<span class="string">&quot;%A, %-d %B, %C%y&quot;</span>).to_string(), <span class="string">&quot;Saturday, 5 September, 2015&quot;</span>);</code></pre></div>
<p>The resulting <code>DelayedFormat</code> can be formatted directly via the <code>Display</code> trait.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(<span class="macro">format!</span>(<span class="string">&quot;{}&quot;</span>, d.format(<span class="string">&quot;%Y-%m-%d&quot;</span>)), <span class="string">&quot;2015-09-05&quot;</span>);
<span class="macro">assert_eq!</span>(<span class="macro">format!</span>(<span class="string">&quot;{}&quot;</span>, d.format(<span class="string">&quot;%A, %-d %B, %C%y&quot;</span>)), <span class="string">&quot;Saturday, 5 September, 2015&quot;</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.iter_days" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#1312-1314">source</a><h4 class="code-header">pub const fn <a href="#method.iter_days" class="fnname">iter_days</a>(&amp;self) -&gt; NaiveDateDaysIterator</h4></section></summary><div class="docblock"><p>Returns an iterator that steps by days across all representable dates.</p>
<h5 id="example-19"><a href="#example-19">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code>
<span class="kw">let </span>expected = [
NaiveDate::from_ymd_opt(<span class="number">2016</span>, <span class="number">2</span>, <span class="number">27</span>).unwrap(),
NaiveDate::from_ymd_opt(<span class="number">2016</span>, <span class="number">2</span>, <span class="number">28</span>).unwrap(),
NaiveDate::from_ymd_opt(<span class="number">2016</span>, <span class="number">2</span>, <span class="number">29</span>).unwrap(),
NaiveDate::from_ymd_opt(<span class="number">2016</span>, <span class="number">3</span>, <span class="number">1</span>).unwrap(),
];
<span class="kw">let </span><span class="kw-2">mut </span>count = <span class="number">0</span>;
<span class="kw">for </span>(idx, d) <span class="kw">in </span>NaiveDate::from_ymd_opt(<span class="number">2016</span>, <span class="number">2</span>, <span class="number">27</span>).unwrap().iter_days().take(<span class="number">4</span>).enumerate() {
<span class="macro">assert_eq!</span>(d, expected[idx]);
count += <span class="number">1</span>;
}
<span class="macro">assert_eq!</span>(count, <span class="number">4</span>);
<span class="kw">for </span>d <span class="kw">in </span>NaiveDate::from_ymd_opt(<span class="number">2016</span>, <span class="number">3</span>, <span class="number">1</span>).unwrap().iter_days().rev().take(<span class="number">4</span>) {
count -= <span class="number">1</span>;
<span class="macro">assert_eq!</span>(d, expected[count]);
}</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.iter_weeks" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#1343-1345">source</a><h4 class="code-header">pub const fn <a href="#method.iter_weeks" class="fnname">iter_weeks</a>(&amp;self) -&gt; NaiveDateWeeksIterator</h4></section></summary><div class="docblock"><p>Returns an iterator that steps by weeks across all representable dates.</p>
<h5 id="example-20"><a href="#example-20">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code>
<span class="kw">let </span>expected = [
NaiveDate::from_ymd_opt(<span class="number">2016</span>, <span class="number">2</span>, <span class="number">27</span>).unwrap(),
NaiveDate::from_ymd_opt(<span class="number">2016</span>, <span class="number">3</span>, <span class="number">5</span>).unwrap(),
NaiveDate::from_ymd_opt(<span class="number">2016</span>, <span class="number">3</span>, <span class="number">12</span>).unwrap(),
NaiveDate::from_ymd_opt(<span class="number">2016</span>, <span class="number">3</span>, <span class="number">19</span>).unwrap(),
];
<span class="kw">let </span><span class="kw-2">mut </span>count = <span class="number">0</span>;
<span class="kw">for </span>(idx, d) <span class="kw">in </span>NaiveDate::from_ymd_opt(<span class="number">2016</span>, <span class="number">2</span>, <span class="number">27</span>).unwrap().iter_weeks().take(<span class="number">4</span>).enumerate() {
<span class="macro">assert_eq!</span>(d, expected[idx]);
count += <span class="number">1</span>;
}
<span class="macro">assert_eq!</span>(count, <span class="number">4</span>);
<span class="kw">for </span>d <span class="kw">in </span>NaiveDate::from_ymd_opt(<span class="number">2016</span>, <span class="number">3</span>, <span class="number">19</span>).unwrap().iter_weeks().rev().take(<span class="number">4</span>) {
count -= <span class="number">1</span>;
<span class="macro">assert_eq!</span>(d, expected[count]);
}</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.week" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#1350-1352">source</a><h4 class="code-header">pub const fn <a href="#method.week" class="fnname">week</a>(&amp;self, start: <a class="enum" href="../enum.Weekday.html" title="enum chrono::Weekday">Weekday</a>) -&gt; <a class="struct" href="struct.NaiveWeek.html" title="struct chrono::naive::NaiveWeek">NaiveWeek</a></h4></section></summary><div class="docblock"><p>Returns the <a href="struct.NaiveWeek.html" title="NaiveWeek"><code>NaiveWeek</code></a> that the date belongs to, starting with the <a href="../enum.Weekday.html" title="Weekday"><code>Weekday</code></a>
specified.</p>
</div></details><details class="rustdoc-toggle" open><summary><section id="associatedconstant.MIN" class="associatedconstant has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#1355">source</a><h4 class="code-header">pub const <a href="#associatedconstant.MIN" class="constant">MIN</a>: <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a> = _</h4></section></summary><div class="docblock"><p>The minimum possible <code>NaiveDate</code> (January 1, 262145 BCE).</p>
</div></details><details class="rustdoc-toggle" open><summary><section id="associatedconstant.MAX" class="associatedconstant has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#1357">source</a><h4 class="code-header">pub const <a href="#associatedconstant.MAX" class="constant">MAX</a>: <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a> = _</h4></section></summary><div class="docblock"><p>The maximum possible <code>NaiveDate</code> (December 31, 262143 CE).</p>
</div></details></div></details></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Add%3CDays%3E-for-NaiveDate" class="impl has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#1797-1803">source</a><a href="#impl-Add%3CDays%3E-for-NaiveDate" class="anchor"></a><h3 class="code-header">impl Add&lt;<a class="struct" href="struct.Days.html" title="struct chrono::naive::Days">Days</a>&gt; for <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Output-3" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Output-3" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Output</a> = <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h4></section></summary><div class='docblock'>The resulting type after applying the <code>+</code> operator.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.add-2" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#1800-1802">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="struct.Days.html" title="struct chrono::naive::Days">Days</a>) -&gt; 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-NaiveDate" class="impl has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#1728-1735">source</a><a href="#impl-Add%3CDuration%3E-for-NaiveDate" class="anchor"></a><h3 class="code-header">impl Add&lt;<a class="struct" href="../struct.Duration.html" title="struct chrono::Duration">Duration</a>&gt; for <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h3></section></summary><div class="docblock"><p>An addition of <code>Duration</code> to <code>NaiveDate</code> discards the fractional days,
rounding to the closest integral number of days towards <code>Duration::zero()</code>.</p>
<p>Panics on underflow or overflow. Use <a href="struct.NaiveDate.html#method.checked_add_signed"><code>NaiveDate::checked_add_signed</code></a> to detect that.</p>
<h4 id="example-36"><a href="#example-36">Example</a></h4>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{Duration, NaiveDate};
<span class="kw">let </span>from_ymd = |y, m, d| NaiveDate::from_ymd_opt(y, m, d).unwrap();
<span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) + Duration::zero(), from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>));
<span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) + Duration::seconds(<span class="number">86399</span>), from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>));
<span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) + Duration::seconds(-<span class="number">86399</span>), from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>));
<span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) + Duration::days(<span class="number">1</span>), from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">2</span>));
<span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) + Duration::days(-<span class="number">1</span>), from_ymd(<span class="number">2013</span>, <span class="number">12</span>, <span class="number">31</span>));
<span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) + Duration::days(<span class="number">364</span>), from_ymd(<span class="number">2014</span>, <span class="number">12</span>, <span class="number">31</span>));
<span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) + Duration::days(<span class="number">365</span><span class="kw-2">*</span><span class="number">4 </span>+ <span class="number">1</span>), from_ymd(<span class="number">2018</span>, <span class="number">1</span>, <span class="number">1</span>));
<span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) + Duration::days(<span class="number">365</span><span class="kw-2">*</span><span class="number">400 </span>+ <span class="number">97</span>), from_ymd(<span class="number">2414</span>, <span class="number">1</span>, <span class="number">1</span>));</code></pre></div>
</div><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Output" 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.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h4></section></summary><div class='docblock'>The resulting type after applying the <code>+</code> operator.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.add" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#1732-1734">source</a><a href="#method.add" 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>) -&gt; <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h4></section></summary><div class='docblock'>Performs the <code>+</code> operation. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Add%3CMonths%3E-for-NaiveDate" class="impl has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#1744-1770">source</a><a href="#impl-Add%3CMonths%3E-for-NaiveDate" class="anchor"></a><h3 class="code-header">impl Add&lt;<a class="struct" href="../struct.Months.html" title="struct chrono::Months">Months</a>&gt; for <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.add-1" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#1767-1769">source</a><a href="#method.add-1" class="anchor"></a><h4 class="code-header">fn <a class="fnname">add</a>(self, months: <a class="struct" href="../struct.Months.html" title="struct chrono::Months">Months</a>) -&gt; Self::Output</h4></section></summary><div class="docblock"><p>An addition of months to <code>NaiveDate</code> clamped to valid days in resulting month.</p>
<h5 id="panics-1"><a href="#panics-1">Panics</a></h5>
<p>Panics if the resulting date would be out of range.</p>
<h5 id="example-37"><a href="#example-37">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{NaiveDate, Months};
<span class="kw">let </span>from_ymd = |y, m, d| NaiveDate::from_ymd_opt(y, m, d).unwrap();
<span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) + Months::new(<span class="number">1</span>), from_ymd(<span class="number">2014</span>, <span class="number">2</span>, <span class="number">1</span>));
<span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) + Months::new(<span class="number">11</span>), from_ymd(<span class="number">2014</span>, <span class="number">12</span>, <span class="number">1</span>));
<span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) + Months::new(<span class="number">12</span>), from_ymd(<span class="number">2015</span>, <span class="number">1</span>, <span class="number">1</span>));
<span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) + Months::new(<span class="number">13</span>), from_ymd(<span class="number">2015</span>, <span class="number">2</span>, <span class="number">1</span>));
<span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">31</span>) + Months::new(<span class="number">1</span>), from_ymd(<span class="number">2014</span>, <span class="number">2</span>, <span class="number">28</span>));
<span class="macro">assert_eq!</span>(from_ymd(<span class="number">2020</span>, <span class="number">1</span>, <span class="number">31</span>) + Months::new(<span class="number">1</span>), from_ymd(<span class="number">2020</span>, <span class="number">2</span>, <span class="number">29</span>));</code></pre></div>
</div></details><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.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h4></section></summary><div class='docblock'>The resulting type after applying the <code>+</code> operator.</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-AddAssign%3CDuration%3E-for-NaiveDate" class="impl has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#1737-1742">source</a><a href="#impl-AddAssign%3CDuration%3E-for-NaiveDate" class="anchor"></a><h3 class="code-header">impl AddAssign&lt;<a class="struct" href="../struct.Duration.html" title="struct chrono::Duration">Duration</a>&gt; for <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.add_assign" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#1739-1741">source</a><a href="#method.add_assign" class="anchor"></a><h4 class="code-header">fn <a class="fnname">add_assign</a>(&amp;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-NaiveDate" class="impl has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#199">source</a><a href="#impl-Clone-for-NaiveDate" class="anchor"></a><h3 class="code-header">impl Clone for <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.clone" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#199">source</a><a href="#method.clone" class="anchor"></a><h4 class="code-header">fn <a class="fnname">clone</a>(&amp;self) -&gt; <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h4></section></summary><div class='docblock'>Returns a copy of the value. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.clone_from" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.clone_from" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">clone_from</a>(&amp;mut self, source: &amp;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-NaiveDate" class="impl has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#1360-1703">source</a><a href="#impl-Datelike-for-NaiveDate" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="../trait.Datelike.html" title="trait chrono::Datelike">Datelike</a> for <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.year" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#1372-1374">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>(&amp;self) -&gt; i32</h4></section></summary><div class="docblock"><p>Returns the year number in the <a href="#calendar-date">calendar date</a>.</p>
<h5 id="example-21"><a href="#example-21">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{NaiveDate, Datelike};
<span class="macro">assert_eq!</span>(NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">8</span>).unwrap().year(), <span class="number">2015</span>);
<span class="macro">assert_eq!</span>(NaiveDate::from_ymd_opt(-<span class="number">308</span>, <span class="number">3</span>, <span class="number">14</span>).unwrap().year(), -<span class="number">308</span>); <span class="comment">// 309 BCE</span></code></pre></div>
</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/naive/date.rs.html#1389-1391">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>(&amp;self) -&gt; u32</h4></section></summary><div class="docblock"><p>Returns the month number starting from 1.</p>
<p>The return value ranges from 1 to 12.</p>
<h5 id="example-22"><a href="#example-22">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{NaiveDate, Datelike};
<span class="macro">assert_eq!</span>(NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">8</span>).unwrap().month(), <span class="number">9</span>);
<span class="macro">assert_eq!</span>(NaiveDate::from_ymd_opt(-<span class="number">308</span>, <span class="number">3</span>, <span class="number">14</span>).unwrap().month(), <span class="number">3</span>);</code></pre></div>
</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/naive/date.rs.html#1406-1408">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>(&amp;self) -&gt; u32</h4></section></summary><div class="docblock"><p>Returns the month number starting from 0.</p>
<p>The return value ranges from 0 to 11.</p>
<h5 id="example-23"><a href="#example-23">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{NaiveDate, Datelike};
<span class="macro">assert_eq!</span>(NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">8</span>).unwrap().month0(), <span class="number">8</span>);
<span class="macro">assert_eq!</span>(NaiveDate::from_ymd_opt(-<span class="number">308</span>, <span class="number">3</span>, <span class="number">14</span>).unwrap().month0(), <span class="number">2</span>);</code></pre></div>
</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/naive/date.rs.html#1446-1448">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>(&amp;self) -&gt; u32</h4></section></summary><div class="docblock"><p>Returns the day of month starting from 1.</p>
<p>The return value ranges from 1 to 31. (The last day of month differs by months.)</p>
<h5 id="example-24"><a href="#example-24">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{NaiveDate, Datelike};
<span class="macro">assert_eq!</span>(NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">8</span>).unwrap().day(), <span class="number">8</span>);
<span class="macro">assert_eq!</span>(NaiveDate::from_ymd_opt(-<span class="number">308</span>, <span class="number">3</span>, <span class="number">14</span>).unwrap().day(), <span class="number">14</span>);</code></pre></div>
<p>Combined with <a href="#method.pred"><code>NaiveDate::pred</code></a>,
one can determine the number of days in a particular month.
(Note that this panics when <code>year</code> is out of range.)</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{NaiveDate, Datelike};
<span class="kw">fn </span>ndays_in_month(year: i32, month: u32) -&gt; u32 {
<span class="comment">// the first day of the next month...
</span><span class="kw">let </span>(y, m) = <span class="kw">if </span>month == <span class="number">12 </span>{ (year + <span class="number">1</span>, <span class="number">1</span>) } <span class="kw">else </span>{ (year, month + <span class="number">1</span>) };
<span class="kw">let </span>d = NaiveDate::from_ymd_opt(y, m, <span class="number">1</span>).unwrap();
<span class="comment">// ...is preceded by the last day of the original month
</span>d.pred_opt().unwrap().day()
}
<span class="macro">assert_eq!</span>(ndays_in_month(<span class="number">2015</span>, <span class="number">8</span>), <span class="number">31</span>);
<span class="macro">assert_eq!</span>(ndays_in_month(<span class="number">2015</span>, <span class="number">9</span>), <span class="number">30</span>);
<span class="macro">assert_eq!</span>(ndays_in_month(<span class="number">2015</span>, <span class="number">12</span>), <span class="number">31</span>);
<span class="macro">assert_eq!</span>(ndays_in_month(<span class="number">2016</span>, <span class="number">2</span>), <span class="number">29</span>);
<span class="macro">assert_eq!</span>(ndays_in_month(<span class="number">2017</span>, <span class="number">2</span>), <span class="number">28</span>);</code></pre></div>
</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/naive/date.rs.html#1463-1465">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>(&amp;self) -&gt; u32</h4></section></summary><div class="docblock"><p>Returns the day of month starting from 0.</p>
<p>The return value ranges from 0 to 30. (The last day of month differs by months.)</p>
<h5 id="example-25"><a href="#example-25">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{NaiveDate, Datelike};
<span class="macro">assert_eq!</span>(NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">8</span>).unwrap().day0(), <span class="number">7</span>);
<span class="macro">assert_eq!</span>(NaiveDate::from_ymd_opt(-<span class="number">308</span>, <span class="number">3</span>, <span class="number">14</span>).unwrap().day0(), <span class="number">13</span>);</code></pre></div>
</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/naive/date.rs.html#1502-1504">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>(&amp;self) -&gt; u32</h4></section></summary><div class="docblock"><p>Returns the day of year starting from 1.</p>
<p>The return value ranges from 1 to 366. (The last day of year differs by years.)</p>
<h5 id="example-26"><a href="#example-26">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{NaiveDate, Datelike};
<span class="macro">assert_eq!</span>(NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">8</span>).unwrap().ordinal(), <span class="number">251</span>);
<span class="macro">assert_eq!</span>(NaiveDate::from_ymd_opt(-<span class="number">308</span>, <span class="number">3</span>, <span class="number">14</span>).unwrap().ordinal(), <span class="number">74</span>);</code></pre></div>
<p>Combined with <a href="#method.pred"><code>NaiveDate::pred</code></a>,
one can determine the number of days in a particular year.
(Note that this panics when <code>year</code> is out of range.)</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{NaiveDate, Datelike};
<span class="kw">fn </span>ndays_in_year(year: i32) -&gt; u32 {
<span class="comment">// the first day of the next year...
</span><span class="kw">let </span>d = NaiveDate::from_ymd_opt(year + <span class="number">1</span>, <span class="number">1</span>, <span class="number">1</span>).unwrap();
<span class="comment">// ...is preceded by the last day of the original year
</span>d.pred_opt().unwrap().ordinal()
}
<span class="macro">assert_eq!</span>(ndays_in_year(<span class="number">2015</span>), <span class="number">365</span>);
<span class="macro">assert_eq!</span>(ndays_in_year(<span class="number">2016</span>), <span class="number">366</span>);
<span class="macro">assert_eq!</span>(ndays_in_year(<span class="number">2017</span>), <span class="number">365</span>);
<span class="macro">assert_eq!</span>(ndays_in_year(<span class="number">2000</span>), <span class="number">366</span>);
<span class="macro">assert_eq!</span>(ndays_in_year(<span class="number">2100</span>), <span class="number">365</span>);</code></pre></div>
</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/naive/date.rs.html#1519-1521">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>(&amp;self) -&gt; u32</h4></section></summary><div class="docblock"><p>Returns the day of year starting from 0.</p>
<p>The return value ranges from 0 to 365. (The last day of year differs by years.)</p>
<h5 id="example-27"><a href="#example-27">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{NaiveDate, Datelike};
<span class="macro">assert_eq!</span>(NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">8</span>).unwrap().ordinal0(), <span class="number">250</span>);
<span class="macro">assert_eq!</span>(NaiveDate::from_ymd_opt(-<span class="number">308</span>, <span class="number">3</span>, <span class="number">14</span>).unwrap().ordinal0(), <span class="number">73</span>);</code></pre></div>
</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/naive/date.rs.html#1534-1536">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>(&amp;self) -&gt; <a class="enum" href="../enum.Weekday.html" title="enum chrono::Weekday">Weekday</a></h4></section></summary><div class="docblock"><p>Returns the day of week.</p>
<h5 id="example-28"><a href="#example-28">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{NaiveDate, Datelike, Weekday};
<span class="macro">assert_eq!</span>(NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">8</span>).unwrap().weekday(), Weekday::Tue);
<span class="macro">assert_eq!</span>(NaiveDate::from_ymd_opt(-<span class="number">308</span>, <span class="number">3</span>, <span class="number">14</span>).unwrap().weekday(), Weekday::Fri);</code></pre></div>
</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/naive/date.rs.html#1566-1575">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>(&amp;self, year: i32) -&gt; Option&lt;<a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a>&gt;</h4></section></summary><div class="docblock"><p>Makes a new <code>NaiveDate</code> with the year number changed.</p>
<p>Returns <code>None</code> when the resulting <code>NaiveDate</code> would be invalid.</p>
<h5 id="example-29"><a href="#example-29">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{NaiveDate, Datelike};
<span class="macro">assert_eq!</span>(NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">8</span>).unwrap().with_year(<span class="number">2016</span>),
<span class="prelude-val">Some</span>(NaiveDate::from_ymd_opt(<span class="number">2016</span>, <span class="number">9</span>, <span class="number">8</span>).unwrap()));
<span class="macro">assert_eq!</span>(NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">8</span>).unwrap().with_year(-<span class="number">308</span>),
<span class="prelude-val">Some</span>(NaiveDate::from_ymd_opt(-<span class="number">308</span>, <span class="number">9</span>, <span class="number">8</span>).unwrap()));</code></pre></div>
<p>A leap day (February 29) is a good example that this method can return <code>None</code>.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert!</span>(NaiveDate::from_ymd_opt(<span class="number">2016</span>, <span class="number">2</span>, <span class="number">29</span>).unwrap().with_year(<span class="number">2015</span>).is_none());
<span class="macro">assert!</span>(NaiveDate::from_ymd_opt(<span class="number">2016</span>, <span class="number">2</span>, <span class="number">29</span>).unwrap().with_year(<span class="number">2020</span>).is_some());</code></pre></div>
</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/naive/date.rs.html#1592-1594">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>(&amp;self, month: u32) -&gt; Option&lt;<a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a>&gt;</h4></section></summary><div class="docblock"><p>Makes a new <code>NaiveDate</code> with the month number (starting from 1) changed.</p>
<p>Returns <code>None</code> when the resulting <code>NaiveDate</code> would be invalid.</p>
<h5 id="example-30"><a href="#example-30">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{NaiveDate, Datelike};
<span class="macro">assert_eq!</span>(NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">8</span>).unwrap().with_month(<span class="number">10</span>),
<span class="prelude-val">Some</span>(NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">10</span>, <span class="number">8</span>).unwrap()));
<span class="macro">assert_eq!</span>(NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">8</span>).unwrap().with_month(<span class="number">13</span>), <span class="prelude-val">None</span>); <span class="comment">// no month 13
</span><span class="macro">assert_eq!</span>(NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">30</span>).unwrap().with_month(<span class="number">2</span>), <span class="prelude-val">None</span>); <span class="comment">// no February 30</span></code></pre></div>
</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/naive/date.rs.html#1611-1614">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>(&amp;self, month0: u32) -&gt; Option&lt;<a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a>&gt;</h4></section></summary><div class="docblock"><p>Makes a new <code>NaiveDate</code> with the month number (starting from 0) changed.</p>
<p>Returns <code>None</code> when the resulting <code>NaiveDate</code> would be invalid.</p>
<h5 id="example-31"><a href="#example-31">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{NaiveDate, Datelike};
<span class="macro">assert_eq!</span>(NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">8</span>).unwrap().with_month0(<span class="number">9</span>),
<span class="prelude-val">Some</span>(NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">10</span>, <span class="number">8</span>).unwrap()));
<span class="macro">assert_eq!</span>(NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">8</span>).unwrap().with_month0(<span class="number">12</span>), <span class="prelude-val">None</span>); <span class="comment">// no month 13
</span><span class="macro">assert_eq!</span>(NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">30</span>).unwrap().with_month0(<span class="number">1</span>), <span class="prelude-val">None</span>); <span class="comment">// no February 30</span></code></pre></div>
</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/naive/date.rs.html#1631-1633">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>(&amp;self, day: u32) -&gt; Option&lt;<a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a>&gt;</h4></section></summary><div class="docblock"><p>Makes a new <code>NaiveDate</code> with the day of month (starting from 1) changed.</p>
<p>Returns <code>None</code> when the resulting <code>NaiveDate</code> would be invalid.</p>
<h5 id="example-32"><a href="#example-32">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{NaiveDate, Datelike};
<span class="macro">assert_eq!</span>(NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">8</span>).unwrap().with_day(<span class="number">30</span>),
<span class="prelude-val">Some</span>(NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">30</span>).unwrap()));
<span class="macro">assert_eq!</span>(NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">8</span>).unwrap().with_day(<span class="number">31</span>),
<span class="prelude-val">None</span>); <span class="comment">// no September 31</span></code></pre></div>
</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/naive/date.rs.html#1650-1653">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>(&amp;self, day0: u32) -&gt; Option&lt;<a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a>&gt;</h4></section></summary><div class="docblock"><p>Makes a new <code>NaiveDate</code> with the day of month (starting from 0) changed.</p>
<p>Returns <code>None</code> when the resulting <code>NaiveDate</code> would be invalid.</p>
<h5 id="example-33"><a href="#example-33">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{NaiveDate, Datelike};
<span class="macro">assert_eq!</span>(NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">8</span>).unwrap().with_day0(<span class="number">29</span>),
<span class="prelude-val">Some</span>(NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">30</span>).unwrap()));
<span class="macro">assert_eq!</span>(NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">8</span>).unwrap().with_day0(<span class="number">30</span>),
<span class="prelude-val">None</span>); <span class="comment">// no September 31</span></code></pre></div>
</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/naive/date.rs.html#1675-1677">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>(&amp;self, ordinal: u32) -&gt; Option&lt;<a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a>&gt;</h4></section></summary><div class="docblock"><p>Makes a new <code>NaiveDate</code> with the day of year (starting from 1) changed.</p>
<p>Returns <code>None</code> when the resulting <code>NaiveDate</code> would be invalid.</p>
<h5 id="example-34"><a href="#example-34">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{NaiveDate, Datelike};
<span class="macro">assert_eq!</span>(NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">1</span>, <span class="number">1</span>).unwrap().with_ordinal(<span class="number">60</span>),
<span class="prelude-val">Some</span>(NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">3</span>, <span class="number">1</span>).unwrap()));
<span class="macro">assert_eq!</span>(NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">1</span>, <span class="number">1</span>).unwrap().with_ordinal(<span class="number">366</span>),
<span class="prelude-val">None</span>); <span class="comment">// 2015 had only 365 days
</span><span class="macro">assert_eq!</span>(NaiveDate::from_ymd_opt(<span class="number">2016</span>, <span class="number">1</span>, <span class="number">1</span>).unwrap().with_ordinal(<span class="number">60</span>),
<span class="prelude-val">Some</span>(NaiveDate::from_ymd_opt(<span class="number">2016</span>, <span class="number">2</span>, <span class="number">29</span>).unwrap()));
<span class="macro">assert_eq!</span>(NaiveDate::from_ymd_opt(<span class="number">2016</span>, <span class="number">1</span>, <span class="number">1</span>).unwrap().with_ordinal(<span class="number">366</span>),
<span class="prelude-val">Some</span>(NaiveDate::from_ymd_opt(<span class="number">2016</span>, <span class="number">12</span>, <span class="number">31</span>).unwrap()));</code></pre></div>
</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/naive/date.rs.html#1699-1702">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>(&amp;self, ordinal0: u32) -&gt; Option&lt;<a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a>&gt;</h4></section></summary><div class="docblock"><p>Makes a new <code>NaiveDate</code> with the day of year (starting from 0) changed.</p>
<p>Returns <code>None</code> when the resulting <code>NaiveDate</code> would be invalid.</p>
<h5 id="example-35"><a href="#example-35">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{NaiveDate, Datelike};
<span class="macro">assert_eq!</span>(NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">1</span>, <span class="number">1</span>).unwrap().with_ordinal0(<span class="number">59</span>),
<span class="prelude-val">Some</span>(NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">3</span>, <span class="number">1</span>).unwrap()));
<span class="macro">assert_eq!</span>(NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">1</span>, <span class="number">1</span>).unwrap().with_ordinal0(<span class="number">365</span>),
<span class="prelude-val">None</span>); <span class="comment">// 2015 had only 365 days
</span><span class="macro">assert_eq!</span>(NaiveDate::from_ymd_opt(<span class="number">2016</span>, <span class="number">1</span>, <span class="number">1</span>).unwrap().with_ordinal0(<span class="number">59</span>),
<span class="prelude-val">Some</span>(NaiveDate::from_ymd_opt(<span class="number">2016</span>, <span class="number">2</span>, <span class="number">29</span>).unwrap()));
<span class="macro">assert_eq!</span>(NaiveDate::from_ymd_opt(<span class="number">2016</span>, <span class="number">1</span>, <span class="number">1</span>).unwrap().with_ordinal0(<span class="number">365</span>),
<span class="prelude-val">Some</span>(NaiveDate::from_ymd_opt(<span class="number">2016</span>, <span class="number">12</span>, <span class="number">31</span>).unwrap()));</code></pre></div>
</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/naive/date.rs.html#1539-1541">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>(&amp;self) -&gt; <a class="struct" href="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.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>(&amp;self) -&gt; (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>(&amp;self) -&gt; 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-NaiveDate" class="impl has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#1993-2012">source</a><a href="#impl-Debug-for-NaiveDate" class="anchor"></a><h3 class="code-header">impl Debug for <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h3></section></summary><div class="docblock"><p>The <code>Debug</code> output of the naive date <code>d</code> is the same as
<a href="../format/strftime/index.html"><code>d.format(&quot;%Y-%m-%d&quot;)</code></a>.</p>
<p>The string printed can be readily parsed via the <code>parse</code> method on <code>str</code>.</p>
<h4 id="example-41"><a href="#example-41">Example</a></h4>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::NaiveDate;
<span class="macro">assert_eq!</span>(<span class="macro">format!</span>(<span class="string">&quot;{:?}&quot;</span>, NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">5</span>).unwrap()), <span class="string">&quot;2015-09-05&quot;</span>);
<span class="macro">assert_eq!</span>(<span class="macro">format!</span>(<span class="string">&quot;{:?}&quot;</span>, NaiveDate::from_ymd_opt( <span class="number">0</span>, <span class="number">1</span>, <span class="number">1</span>).unwrap()), <span class="string">&quot;0000-01-01&quot;</span>);
<span class="macro">assert_eq!</span>(<span class="macro">format!</span>(<span class="string">&quot;{:?}&quot;</span>, NaiveDate::from_ymd_opt(<span class="number">9999</span>, <span class="number">12</span>, <span class="number">31</span>).unwrap()), <span class="string">&quot;9999-12-31&quot;</span>);</code></pre></div>
<p>ISO 8601 requires an explicit sign for years before 1 BCE or after 9999 CE.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(<span class="macro">format!</span>(<span class="string">&quot;{:?}&quot;</span>, NaiveDate::from_ymd_opt( -<span class="number">1</span>, <span class="number">1</span>, <span class="number">1</span>).unwrap()), <span class="string">&quot;-0001-01-01&quot;</span>);
<span class="macro">assert_eq!</span>(<span class="macro">format!</span>(<span class="string">&quot;{:?}&quot;</span>, NaiveDate::from_ymd_opt(<span class="number">10000</span>, <span class="number">12</span>, <span class="number">31</span>).unwrap()), <span class="string">&quot;+10000-12-31&quot;</span>);</code></pre></div>
</div><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/naive/date.rs.html#1994-2011">source</a><a href="#method.fmt" class="anchor"></a><h4 class="code-header">fn <a class="fnname">fmt</a>(&amp;self, f: &amp;mut Formatter&lt;'_&gt;) -&gt; 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-NaiveDate" class="impl has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#2089-2093">source</a><a href="#impl-Default-for-NaiveDate" class="anchor"></a><h3 class="code-header">impl Default for <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h3></section></summary><div class="docblock"><p>The default value for a NaiveDate is 1st of January 1970.</p>
<h4 id="example-44"><a href="#example-44">Example</a></h4>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::NaiveDate;
<span class="kw">let </span>default_date = NaiveDate::default();
<span class="macro">assert_eq!</span>(default_date, NaiveDate::from_ymd_opt(<span class="number">1970</span>, <span class="number">1</span>, <span class="number">1</span>).unwrap());</code></pre></div>
</div><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/naive/date.rs.html#2090-2092">source</a><a href="#method.default" class="anchor"></a><h4 class="code-header">fn <a class="fnname">default</a>() -&gt; 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-NaiveDate" class="impl has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#2036-2040">source</a><a href="#impl-Display-for-NaiveDate" class="anchor"></a><h3 class="code-header">impl Display for <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h3></section></summary><div class="docblock"><p>The <code>Display</code> output of the naive date <code>d</code> is the same as
<a href="../format/strftime/index.html"><code>d.format(&quot;%Y-%m-%d&quot;)</code></a>.</p>
<p>The string printed can be readily parsed via the <code>parse</code> method on <code>str</code>.</p>
<h4 id="example-42"><a href="#example-42">Example</a></h4>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::NaiveDate;
<span class="macro">assert_eq!</span>(<span class="macro">format!</span>(<span class="string">&quot;{}&quot;</span>, NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">5</span>).unwrap()), <span class="string">&quot;2015-09-05&quot;</span>);
<span class="macro">assert_eq!</span>(<span class="macro">format!</span>(<span class="string">&quot;{}&quot;</span>, NaiveDate::from_ymd_opt( <span class="number">0</span>, <span class="number">1</span>, <span class="number">1</span>).unwrap()), <span class="string">&quot;0000-01-01&quot;</span>);
<span class="macro">assert_eq!</span>(<span class="macro">format!</span>(<span class="string">&quot;{}&quot;</span>, NaiveDate::from_ymd_opt(<span class="number">9999</span>, <span class="number">12</span>, <span class="number">31</span>).unwrap()), <span class="string">&quot;9999-12-31&quot;</span>);</code></pre></div>
<p>ISO 8601 requires an explicit sign for years before 1 BCE or after 9999 CE.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(<span class="macro">format!</span>(<span class="string">&quot;{}&quot;</span>, NaiveDate::from_ymd_opt( -<span class="number">1</span>, <span class="number">1</span>, <span class="number">1</span>).unwrap()), <span class="string">&quot;-0001-01-01&quot;</span>);
<span class="macro">assert_eq!</span>(<span class="macro">format!</span>(<span class="string">&quot;{}&quot;</span>, NaiveDate::from_ymd_opt(<span class="number">10000</span>, <span class="number">12</span>, <span class="number">31</span>).unwrap()), <span class="string">&quot;+10000-12-31&quot;</span>);</code></pre></div>
</div><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/naive/date.rs.html#2037-2039">source</a><a href="#method.fmt-1" class="anchor"></a><h4 class="code-header">fn <a class="fnname">fmt</a>(&amp;self, f: &amp;mut Formatter&lt;'_&gt;) -&gt; 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-From%3CNaiveDateTime%3E-for-NaiveDate" class="impl has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#1886-1890">source</a><a href="#impl-From%3CNaiveDateTime%3E-for-NaiveDate" class="anchor"></a><h3 class="code-header">impl From&lt;<a class="struct" href="struct.NaiveDateTime.html" title="struct chrono::naive::NaiveDateTime">NaiveDateTime</a>&gt; for <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#1887-1889">source</a><a href="#method.from" class="anchor"></a><h4 class="code-header">fn <a class="fnname">from</a>(naive_datetime: <a class="struct" href="struct.NaiveDateTime.html" title="struct chrono::naive::NaiveDateTime">NaiveDateTime</a>) -&gt; Self</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-NaiveDate" class="impl has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#2058-2077">source</a><a href="#impl-FromStr-for-NaiveDate" class="anchor"></a><h3 class="code-header">impl FromStr for <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h3></section></summary><div class="docblock"><p>Parsing a <code>str</code> into a <code>NaiveDate</code> uses the same format,
<a href="../format/strftime/index.html"><code>%Y-%m-%d</code></a>, as in <code>Debug</code> and <code>Display</code>.</p>
<h4 id="example-43"><a href="#example-43">Example</a></h4>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::NaiveDate;
<span class="kw">let </span>d = NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">18</span>).unwrap();
<span class="macro">assert_eq!</span>(<span class="string">&quot;2015-09-18&quot;</span>.parse::&lt;NaiveDate&gt;(), <span class="prelude-val">Ok</span>(d));
<span class="kw">let </span>d = NaiveDate::from_ymd_opt(<span class="number">12345</span>, <span class="number">6</span>, <span class="number">7</span>).unwrap();
<span class="macro">assert_eq!</span>(<span class="string">&quot;+12345-6-7&quot;</span>.parse::&lt;NaiveDate&gt;(), <span class="prelude-val">Ok</span>(d));
<span class="macro">assert!</span>(<span class="string">&quot;foo&quot;</span>.parse::&lt;NaiveDate&gt;().is_err());</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/naive/date.rs.html#2061-2076">source</a><a href="#method.from_str" class="anchor"></a><h4 class="code-header">fn <a class="fnname">from_str</a>(s: &amp;str) -&gt; <a class="type" href="../format/type.ParseResult.html" title="type chrono::format::ParseResult">ParseResult</a>&lt;<a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a>&gt;</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-NaiveDate" class="impl has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#199">source</a><a href="#impl-Hash-for-NaiveDate" class="anchor"></a><h3 class="code-header">impl Hash for <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.hash" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#199">source</a><a href="#method.hash" class="anchor"></a><h4 class="code-header">fn <a class="fnname">hash</a>&lt;__H:&nbsp;Hasher&gt;(&amp;self, state: &amp;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>&lt;H&gt;(data: &amp;[Self], state: &amp;mut H)<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;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-NaiveDate" class="impl has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#199">source</a><a href="#impl-Ord-for-NaiveDate" class="anchor"></a><h3 class="code-header">impl Ord for <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.cmp" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#199">source</a><a href="#method.cmp" class="anchor"></a><h4 class="code-header">fn <a class="fnname">cmp</a>(&amp;self, other: &amp;<a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a>) -&gt; 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) -&gt; 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) -&gt; 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) -&gt; Self<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: PartialOrd&lt;Self&gt;,</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%3CNaiveDate%3E-for-NaiveDate" class="impl has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#199">source</a><a href="#impl-PartialEq%3CNaiveDate%3E-for-NaiveDate" class="anchor"></a><h3 class="code-header">impl PartialEq&lt;<a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a>&gt; for <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.eq" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#199">source</a><a href="#method.eq" class="anchor"></a><h4 class="code-header">fn <a class="fnname">eq</a>(&amp;self, other: &amp;<a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a>) -&gt; 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>(&amp;self, other: &amp;Rhs) -&gt; 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%3CNaiveDate%3E-for-NaiveDate" class="impl has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#199">source</a><a href="#impl-PartialOrd%3CNaiveDate%3E-for-NaiveDate" class="anchor"></a><h3 class="code-header">impl PartialOrd&lt;<a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a>&gt; for <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.partial_cmp" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#199">source</a><a href="#method.partial_cmp" class="anchor"></a><h4 class="code-header">fn <a class="fnname">partial_cmp</a>(&amp;self, other: &amp;<a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a>) -&gt; Option&lt;Ordering&gt;</h4></section></summary><div class='docblock'>This method returns an ordering between <code>self</code> and <code>other</code> values if one exists. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.lt" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.lt" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">lt</a>(&amp;self, other: &amp;Rhs) -&gt; 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>&lt;</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>(&amp;self, other: &amp;Rhs) -&gt; 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>&lt;=</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>(&amp;self, other: &amp;Rhs) -&gt; 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>&gt;</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>(&amp;self, other: &amp;Rhs) -&gt; 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>&gt;=</code>
operator. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Sub%3CDays%3E-for-NaiveDate" class="impl has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#1805-1811">source</a><a href="#impl-Sub%3CDays%3E-for-NaiveDate" class="anchor"></a><h3 class="code-header">impl Sub&lt;<a class="struct" href="struct.Days.html" title="struct chrono::naive::Days">Days</a>&gt; for <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Output-4" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Output-4" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Output</a> = <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h4></section></summary><div class='docblock'>The resulting type after applying the <code>-</code> operator.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.sub-1" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#1808-1810">source</a><a href="#method.sub-1" class="anchor"></a><h4 class="code-header">fn <a class="fnname">sub</a>(self, days: <a class="struct" href="struct.Days.html" title="struct chrono::naive::Days">Days</a>) -&gt; 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-NaiveDate" class="impl has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#1837-1844">source</a><a href="#impl-Sub%3CDuration%3E-for-NaiveDate" class="anchor"></a><h3 class="code-header">impl Sub&lt;<a class="struct" href="../struct.Duration.html" title="struct chrono::Duration">Duration</a>&gt; for <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h3></section></summary><div class="docblock"><p>A subtraction of <code>Duration</code> from <code>NaiveDate</code> discards the fractional days,
rounding to the closest integral number of days towards <code>Duration::zero()</code>.
It is the same as the addition with a negated <code>Duration</code>.</p>
<p>Panics on underflow or overflow. Use <a href="struct.NaiveDate.html#method.checked_sub_signed"><code>NaiveDate::checked_sub_signed</code></a> to detect that.</p>
<h4 id="example-39"><a href="#example-39">Example</a></h4>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{Duration, NaiveDate};
<span class="kw">let </span>from_ymd = |y, m, d| NaiveDate::from_ymd_opt(y, m, d).unwrap();
<span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) - Duration::zero(), from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>));
<span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) - Duration::seconds(<span class="number">86399</span>), from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>));
<span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) - Duration::seconds(-<span class="number">86399</span>), from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>));
<span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) - Duration::days(<span class="number">1</span>), from_ymd(<span class="number">2013</span>, <span class="number">12</span>, <span class="number">31</span>));
<span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) - Duration::days(-<span class="number">1</span>), from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">2</span>));
<span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) - Duration::days(<span class="number">364</span>), from_ymd(<span class="number">2013</span>, <span class="number">1</span>, <span class="number">2</span>));
<span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) - Duration::days(<span class="number">365</span><span class="kw-2">*</span><span class="number">4 </span>+ <span class="number">1</span>), from_ymd(<span class="number">2010</span>, <span class="number">1</span>, <span class="number">1</span>));
<span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) - Duration::days(<span class="number">365</span><span class="kw-2">*</span><span class="number">400 </span>+ <span class="number">97</span>), from_ymd(<span class="number">1614</span>, <span class="number">1</span>, <span class="number">1</span>));</code></pre></div>
</div><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Output-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.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h4></section></summary><div class='docblock'>The resulting type after applying the <code>-</code> operator.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.sub-2" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#1841-1843">source</a><a href="#method.sub-2" class="anchor"></a><h4 class="code-header">fn <a class="fnname">sub</a>(self, rhs: <a class="struct" href="../struct.Duration.html" title="struct chrono::Duration">OldDuration</a>) -&gt; <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h4></section></summary><div class='docblock'>Performs the <code>-</code> operation. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Sub%3CMonths%3E-for-NaiveDate" class="impl has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#1772-1795">source</a><a href="#impl-Sub%3CMonths%3E-for-NaiveDate" class="anchor"></a><h3 class="code-header">impl Sub&lt;<a class="struct" href="../struct.Months.html" title="struct chrono::Months">Months</a>&gt; for <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.sub" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#1792-1794">source</a><a href="#method.sub" class="anchor"></a><h4 class="code-header">fn <a class="fnname">sub</a>(self, months: <a class="struct" href="../struct.Months.html" title="struct chrono::Months">Months</a>) -&gt; Self::Output</h4></section></summary><div class="docblock"><p>A subtraction of Months from <code>NaiveDate</code> clamped to valid days in resulting month.</p>
<h5 id="panics-2"><a href="#panics-2">Panics</a></h5>
<p>Panics if the resulting date would be out of range.</p>
<h5 id="example-38"><a href="#example-38">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{NaiveDate, Months};
<span class="kw">let </span>from_ymd = |y, m, d| NaiveDate::from_ymd_opt(y, m, d).unwrap();
<span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) - Months::new(<span class="number">11</span>), from_ymd(<span class="number">2013</span>, <span class="number">2</span>, <span class="number">1</span>));
<span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) - Months::new(<span class="number">12</span>), from_ymd(<span class="number">2013</span>, <span class="number">1</span>, <span class="number">1</span>));
<span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) - Months::new(<span class="number">13</span>), from_ymd(<span class="number">2012</span>, <span class="number">12</span>, <span class="number">1</span>));</code></pre></div>
</div></details><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.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h4></section></summary><div class='docblock'>The resulting type after applying the <code>-</code> operator.</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Sub%3CNaiveDate%3E-for-NaiveDate" class="impl has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#1877-1884">source</a><a href="#impl-Sub%3CNaiveDate%3E-for-NaiveDate" class="anchor"></a><h3 class="code-header">impl Sub&lt;<a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a>&gt; for <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h3></section></summary><div class="docblock"><p>Subtracts another <code>NaiveDate</code> from the current date.
Returns a <code>Duration</code> of integral numbers.</p>
<p>This does not overflow or underflow at all,
as all possible output fits in the range of <code>Duration</code>.</p>
<p>The implementation is a wrapper around
<a href="#method.signed_duration_since"><code>NaiveDate::signed_duration_since</code></a>.</p>
<h4 id="example-40"><a href="#example-40">Example</a></h4>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{Duration, NaiveDate};
<span class="kw">let </span>from_ymd = |y, m, d| NaiveDate::from_ymd_opt(y, m, d).unwrap();
<span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) - from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>), Duration::zero());
<span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) - from_ymd(<span class="number">2013</span>, <span class="number">12</span>, <span class="number">31</span>), Duration::days(<span class="number">1</span>));
<span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) - from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">2</span>), Duration::days(-<span class="number">1</span>));
<span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) - from_ymd(<span class="number">2013</span>, <span class="number">9</span>, <span class="number">23</span>), Duration::days(<span class="number">100</span>));
<span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) - from_ymd(<span class="number">2013</span>, <span class="number">1</span>, <span class="number">1</span>), Duration::days(<span class="number">365</span>));
<span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) - from_ymd(<span class="number">2010</span>, <span class="number">1</span>, <span class="number">1</span>), Duration::days(<span class="number">365</span><span class="kw-2">*</span><span class="number">4 </span>+ <span class="number">1</span>));
<span class="macro">assert_eq!</span>(from_ymd(<span class="number">2014</span>, <span class="number">1</span>, <span class="number">1</span>) - from_ymd(<span class="number">1614</span>, <span class="number">1</span>, <span class="number">1</span>), Duration::days(<span class="number">365</span><span class="kw-2">*</span><span class="number">400 </span>+ <span class="number">97</span>));</code></pre></div>
</div><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.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-3" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#1881-1883">source</a><a href="#method.sub-3" class="anchor"></a><h4 class="code-header">fn <a class="fnname">sub</a>(self, rhs: <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a>) -&gt; <a class="struct" href="../struct.Duration.html" title="struct chrono::Duration">OldDuration</a></h4></section></summary><div class='docblock'>Performs the <code>-</code> operation. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-SubAssign%3CDuration%3E-for-NaiveDate" class="impl has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#1846-1851">source</a><a href="#impl-SubAssign%3CDuration%3E-for-NaiveDate" class="anchor"></a><h3 class="code-header">impl SubAssign&lt;<a class="struct" href="../struct.Duration.html" title="struct chrono::Duration">Duration</a>&gt; for <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.sub_assign" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#1848-1850">source</a><a href="#method.sub_assign" class="anchor"></a><h4 class="code-header">fn <a class="fnname">sub_assign</a>(&amp;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><section id="impl-Copy-for-NaiveDate" class="impl has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#199">source</a><a href="#impl-Copy-for-NaiveDate" class="anchor"></a><h3 class="code-header">impl Copy for <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h3></section><section id="impl-Eq-for-NaiveDate" class="impl has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#199">source</a><a href="#impl-Eq-for-NaiveDate" class="anchor"></a><h3 class="code-header">impl Eq for <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h3></section><section id="impl-StructuralEq-for-NaiveDate" class="impl has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#199">source</a><a href="#impl-StructuralEq-for-NaiveDate" class="anchor"></a><h3 class="code-header">impl StructuralEq for <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h3></section><section id="impl-StructuralPartialEq-for-NaiveDate" class="impl has-srclink"><a class="srclink rightside" href="../../src/chrono/naive/date.rs.html#199">source</a><a href="#impl-StructuralPartialEq-for-NaiveDate" class="anchor"></a><h3 class="code-header">impl StructuralPartialEq for <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h3></section></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><section id="impl-RefUnwindSafe-for-NaiveDate" class="impl has-srclink"><a href="#impl-RefUnwindSafe-for-NaiveDate" class="anchor"></a><h3 class="code-header">impl RefUnwindSafe for <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h3></section><section id="impl-Send-for-NaiveDate" class="impl has-srclink"><a href="#impl-Send-for-NaiveDate" class="anchor"></a><h3 class="code-header">impl Send for <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h3></section><section id="impl-Sync-for-NaiveDate" class="impl has-srclink"><a href="#impl-Sync-for-NaiveDate" class="anchor"></a><h3 class="code-header">impl Sync for <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h3></section><section id="impl-Unpin-for-NaiveDate" class="impl has-srclink"><a href="#impl-Unpin-for-NaiveDate" class="anchor"></a><h3 class="code-header">impl Unpin for <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h3></section><section id="impl-UnwindSafe-for-NaiveDate" class="impl has-srclink"><a href="#impl-UnwindSafe-for-NaiveDate" class="anchor"></a><h3 class="code-header">impl UnwindSafe for <a class="struct" href="struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a></h3></section></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Any-for-NaiveDate" class="impl has-srclink"><a href="#impl-Any-for-NaiveDate" class="anchor"></a><h3 class="code-header">impl&lt;T&gt; Any for T<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;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>(&amp;self) -&gt; 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-NaiveDate" class="impl has-srclink"><a href="#impl-Borrow%3CT%3E-for-NaiveDate" class="anchor"></a><h3 class="code-header">impl&lt;T&gt; Borrow&lt;T&gt; for T<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;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>(&amp;self) -&gt; &amp;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-NaiveDate" class="impl has-srclink"><a href="#impl-BorrowMut%3CT%3E-for-NaiveDate" class="anchor"></a><h3 class="code-header">impl&lt;T&gt; BorrowMut&lt;T&gt; for T<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;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>(&amp;mut self) -&gt; &amp;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-NaiveDate" class="impl has-srclink"><a href="#impl-From%3CT%3E-for-NaiveDate" class="anchor"></a><h3 class="code-header">impl&lt;T&gt; From&lt;T&gt; for T</h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from-1" class="method trait-impl has-srclink"><span class="since rightside" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span><a href="#method.from-1" class="anchor"></a><h4 class="code-header">fn <a class="fnname">from</a>(t: T) -&gt; 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-NaiveDate" class="impl has-srclink"><a href="#impl-Into%3CU%3E-for-NaiveDate" class="anchor"></a><h3 class="code-header">impl&lt;T, U&gt; Into&lt;U&gt; for T<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: From&lt;T&gt;,</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) -&gt; 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]&lt;T&gt; for U</code> chooses to do.</p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-ToOwned-for-NaiveDate" class="impl has-srclink"><a href="#impl-ToOwned-for-NaiveDate" class="anchor"></a><h3 class="code-header">impl&lt;T&gt; ToOwned for T<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;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>(&amp;self) -&gt; 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>(&amp;self, target: &amp;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-NaiveDate" class="impl has-srclink"><a href="#impl-ToString-for-NaiveDate" class="anchor"></a><h3 class="code-header">impl&lt;T&gt; ToString for T<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;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>(&amp;self) -&gt; 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-NaiveDate" class="impl has-srclink"><a href="#impl-TryFrom%3CU%3E-for-NaiveDate" class="anchor"></a><h3 class="code-header">impl&lt;T, U&gt; TryFrom&lt;U&gt; for T<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: Into&lt;T&gt;,</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) -&gt; Result&lt;T, &lt;T as TryFrom&lt;U&gt;&gt;::Error&gt;</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-NaiveDate" class="impl has-srclink"><a href="#impl-TryInto%3CU%3E-for-NaiveDate" class="anchor"></a><h3 class="code-header">impl&lt;T, U&gt; TryInto&lt;U&gt; for T<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: TryFrom&lt;T&gt;,</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> = &lt;U as TryFrom&lt;T&gt;&gt;::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) -&gt; Result&lt;U, &lt;U as TryFrom&lt;T&gt;&gt;::Error&gt;</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>