pnmixer-rust/chrono/naive/datetime/struct.NaiveDateTime.html
2017-07-15 01:30:16 +02:00

593 lines
93 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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="API documentation for the Rust `NaiveDateTime` struct in crate `chrono`.">
<meta name="keywords" content="rust, rustlang, rust-lang, NaiveDateTime">
<title>chrono::naive::datetime::NaiveDateTime - Rust</title>
<link rel="stylesheet" type="text/css" href="../../../normalize.css">
<link rel="stylesheet" type="text/css" href="../../../rustdoc.css">
<link rel="stylesheet" type="text/css" href="../../../main.css">
</head>
<body class="rustdoc struct">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
<p class='location'>Struct NaiveDateTime</p><div class="block items"><ul><li><a href="#methods">Methods</a></li><li><a href="#implementations">Trait Implementations</a></li></ul></div><p class='location'><a href='../../index.html'>chrono</a>::<wbr><a href='../index.html'>naive</a>::<wbr><a href='index.html'>datetime</a></p><script>window.sidebarCurrent = {name: 'NaiveDateTime', ty: 'struct', relpath: ''};</script><script defer src="sidebar-items.js"></script>
</nav>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press S to search, ? for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content">
<h1 class='fqn'><span class='in-band'>Struct <a href='../../index.html'>chrono</a>::<wbr><a href='../index.html'>naive</a>::<wbr><a href='index.html'>datetime</a>::<wbr><a class="struct" href=''>NaiveDateTime</a></span><span class='out-of-band'><span id='render-detail'>
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
[<span class='inner'>&#x2212;</span>]
</a>
</span><a class='srclink' href='../../../src/chrono/naive/datetime.rs.html#21-24' title='goto source code'>[src]</a></span></h1>
<pre class='rust struct'>pub struct NaiveDateTime { /* fields omitted */ }</pre><div class='docblock'><p>ISO 8601 combined date and time without timezone.</p>
</div><h2 id='methods'>Methods</h2><h3 class='impl'><span class='in-band'><code>impl <a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/chrono/naive/datetime.rs.html#26-197' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.new' class="method"><span id='new.v' class='invisible'><code>fn <a href='#method.new' class='fnname'>new</a>(date: <a class="struct" href="../../../chrono/naive/date/struct.NaiveDate.html" title="struct chrono::naive::date::NaiveDate">NaiveDate</a>, time: <a class="struct" href="../../../chrono/naive/time/struct.NaiveTime.html" title="struct chrono::naive::time::NaiveTime">NaiveTime</a>) -&gt; <a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a></code></span></h4>
<div class='docblock'><p>Makes a new <code>NaiveDateTime</code> from date and time components.
Equivalent to <code>date.and_time(time)</code> and many other helper constructors on <code>NaiveDate</code>.</p>
</div><h4 id='method.from_timestamp' class="method"><span id='from_timestamp.v' class='invisible'><code>fn <a href='#method.from_timestamp' class='fnname'>from_timestamp</a>(secs: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a>, nsecs: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -&gt; <a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a></code></span></h4>
<div class='docblock'><p>Makes a new <code>NaiveDateTime</code> from the number of non-leap seconds
since the midnight UTC on January 1, 1970 (aka &quot;UNIX timestamp&quot;)
and the number of nanoseconds since the last whole non-leap second.</p>
<p>Panics on the out-of-range number of seconds and/or invalid nanosecond.</p>
</div><h4 id='method.from_timestamp_opt' class="method"><span id='from_timestamp_opt.v' class='invisible'><code>fn <a href='#method.from_timestamp_opt' class='fnname'>from_timestamp_opt</a>(secs: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a>, nsecs: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a>&gt;</code></span></h4>
<div class='docblock'><p>Makes a new <code>NaiveDateTime</code> from the number of non-leap seconds
since the midnight UTC on January 1, 1970 (aka &quot;UNIX timestamp&quot;)
and the number of nanoseconds since the last whole non-leap second.</p>
<p>Returns <code>None</code> on the out-of-range number of seconds and/or invalid nanosecond.</p>
</div><h4 id='method.from_num_seconds_from_unix_epoch' class="method"><span id='from_num_seconds_from_unix_epoch.v' class='invisible'><code>fn <a href='#method.from_num_seconds_from_unix_epoch' class='fnname'>from_num_seconds_from_unix_epoch</a>(secs: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a>, nsecs: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -&gt; <a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a></code></span></h4>
<div class='docblock'><p><em>Deprecated:</em> Same to <a href="#method.from_timestamp"><code>NaiveDateTime::from_timestamp</code></a>.</p>
</div><h4 id='method.from_num_seconds_from_unix_epoch_opt' class="method"><span id='from_num_seconds_from_unix_epoch_opt.v' class='invisible'><code>fn <a href='#method.from_num_seconds_from_unix_epoch_opt' class='fnname'>from_num_seconds_from_unix_epoch_opt</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;secs: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;nsecs: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a><br>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a>&gt;</code></span></h4>
<div class='docblock'><p><em>Deprecated:</em> Same to <a href="#method.from_timestamp_opt"><code>NaiveDateTime::from_timestamp_opt</code></a>.</p>
</div><h4 id='method.parse_from_str' class="method"><span id='parse_from_str.v' class='invisible'><code>fn <a href='#method.parse_from_str' class='fnname'>parse_from_str</a>(s: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>, fmt: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -&gt; <a class="type" href="../../../chrono/format/type.ParseResult.html" title="type chrono::format::ParseResult">ParseResult</a>&lt;<a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a>&gt;</code></span></h4>
<div class='docblock'><p>Parses a string with the specified format string and returns a new <code>NaiveDateTime</code>.
See the <a href="../../format/strftime/index.html"><code>format::strftime</code> module</a>
on the supported escape sequences.</p>
</div><h4 id='method.date' class="method"><span id='date.v' class='invisible'><code>fn <a href='#method.date' class='fnname'>date</a>(&amp;self) -&gt; <a class="struct" href="../../../chrono/naive/date/struct.NaiveDate.html" title="struct chrono::naive::date::NaiveDate">NaiveDate</a></code></span></h4>
<div class='docblock'><p>Retrieves a date component.</p>
</div><h4 id='method.time' class="method"><span id='time.v' class='invisible'><code>fn <a href='#method.time' class='fnname'>time</a>(&amp;self) -&gt; <a class="struct" href="../../../chrono/naive/time/struct.NaiveTime.html" title="struct chrono::naive::time::NaiveTime">NaiveTime</a></code></span></h4>
<div class='docblock'><p>Retrieves a time component.</p>
</div><h4 id='method.timestamp' class="method"><span id='timestamp.v' class='invisible'><code>fn <a href='#method.timestamp' class='fnname'>timestamp</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a></code></span></h4>
<div class='docblock'><p>Returns the number of non-leap seconds since the midnight on January 1, 1970.</p>
<p>Note that this does <em>not</em> account for the timezone!
The true &quot;UNIX timestamp&quot; would count seconds since the midnight <em>UTC</em> on the epoch.</p>
</div><h4 id='method.timestamp_subsec_millis' class="method"><span id='timestamp_subsec_millis.v' class='invisible'><code>fn <a href='#method.timestamp_subsec_millis' class='fnname'>timestamp_subsec_millis</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a></code></span></h4>
<div class='docblock'><p>Returns the number of milliseconds since the last whole non-leap second.</p>
<p>The return value ranges from 0 to 999,
or for <a href="../time/index.html#leap-second-handling">leap seconds</a>, to 1,999.</p>
</div><h4 id='method.timestamp_subsec_micros' class="method"><span id='timestamp_subsec_micros.v' class='invisible'><code>fn <a href='#method.timestamp_subsec_micros' class='fnname'>timestamp_subsec_micros</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a></code></span></h4>
<div class='docblock'><p>Returns the number of microseconds since the last whole non-leap second.</p>
<p>The return value ranges from 0 to 999,999,
or for <a href="../time/index.html#leap-second-handling">leap seconds</a>, to 1,999,999.</p>
</div><h4 id='method.timestamp_subsec_nanos' class="method"><span id='timestamp_subsec_nanos.v' class='invisible'><code>fn <a href='#method.timestamp_subsec_nanos' class='fnname'>timestamp_subsec_nanos</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a></code></span></h4>
<div class='docblock'><p>Returns the number of nanoseconds since the last whole non-leap second.</p>
<p>The return value ranges from 0 to 999,999,999,
or for <a href="../time/index.html#leap-second-handling">leap seconds</a>, to 1,999,999,999.</p>
</div><h4 id='method.num_seconds_from_unix_epoch' class="method"><span id='num_seconds_from_unix_epoch.v' class='invisible'><code>fn <a href='#method.num_seconds_from_unix_epoch' class='fnname'>num_seconds_from_unix_epoch</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a></code></span></h4>
<div class='docblock'><p><em>Deprecated:</em> Same to <a href="#method.timestamp"><code>NaiveDateTime::timestamp</code></a>.</p>
</div><h4 id='method.checked_add' class="method"><span id='checked_add.v' class='invisible'><code>fn <a href='#method.checked_add' class='fnname'>checked_add</a>(self, rhs: <a class="struct" href="../../../chrono/duration/struct.Duration.html" title="struct chrono::duration::Duration">Duration</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a>&gt;</code></span></h4>
<div class='docblock'><p>Adds given <code>Duration</code> to the current date and time.</p>
<p>Returns <code>None</code> when it will result in overflow.</p>
</div><h4 id='method.checked_sub' class="method"><span id='checked_sub.v' class='invisible'><code>fn <a href='#method.checked_sub' class='fnname'>checked_sub</a>(self, rhs: <a class="struct" href="../../../chrono/duration/struct.Duration.html" title="struct chrono::duration::Duration">Duration</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a>&gt;</code></span></h4>
<div class='docblock'><p>Subtracts given <code>Duration</code> from the current date and time.</p>
<p>Returns <code>None</code> when it will result in overflow.</p>
</div><h4 id='method.format_with_items' class="method"><span id='format_with_items.v' class='invisible'><code>fn <a href='#method.format_with_items' class='fnname'>format_with_items</a>&lt;'a, I&gt;(&amp;self, items: I) -&gt; <a class="struct" href="../../../chrono/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: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>&lt;Item = <a class="enum" href="../../../chrono/format/enum.Item.html" title="enum chrono::format::Item">Item</a>&lt;'a&gt;&gt; + <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,&nbsp;</span></code></span></h4>
<div class='docblock'><p>Formats the combined date and time with the specified formatting items.</p>
</div><h4 id='method.format' class="method"><span id='format.v' class='invisible'><code>fn <a href='#method.format' class='fnname'>format</a>&lt;'a&gt;(&amp;self, fmt: &amp;'a <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -&gt; <a class="struct" href="../../../chrono/format/struct.DelayedFormat.html" title="struct chrono::format::DelayedFormat">DelayedFormat</a>&lt;<a class="struct" href="../../../chrono/format/strftime/struct.StrftimeItems.html" title="struct chrono::format::strftime::StrftimeItems">StrftimeItems</a>&lt;'a&gt;&gt;</code></span></h4>
<div class='docblock'><p>Formats the combined date and time 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>
</div></div><h2 id='implementations'>Trait Implementations</h2><h3 class='impl'><span class='in-band'><code>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a> for <a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/chrono/naive/datetime.rs.html#20' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.eq' class="method"><span id='eq.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq' class='fnname'>eq</a>(&amp;self, __arg_0: &amp;<a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span></h4>
<div class='docblock'><p>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used by <code>==</code>. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq">Read more</a></p>
</div><h4 id='method.ne' class="method"><span id='ne.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#method.ne' class='fnname'>ne</a>(&amp;self, __arg_0: &amp;<a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span></h4>
<div class='docblock'><p>This method tests for <code>!=</code>.</p>
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> for <a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/chrono/naive/datetime.rs.html#20' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'></div><h3 class='impl'><span class='in-band'><code>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a> for <a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/chrono/naive/datetime.rs.html#20' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.partial_cmp' class="method"><span id='partial_cmp.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#tymethod.partial_cmp' class='fnname'>partial_cmp</a>(&amp;self, __arg_0: &amp;<a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="enum" href="https://doc.rust-lang.org/nightly/core/cmp/enum.Ordering.html" title="enum core::cmp::Ordering">Ordering</a>&gt;</code></span></h4>
<div class='docblock'><p>This method returns an ordering between <code>self</code> and <code>other</code> values if one exists. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#tymethod.partial_cmp">Read more</a></p>
</div><h4 id='method.lt' class="method"><span id='lt.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.lt' class='fnname'>lt</a>(&amp;self, __arg_0: &amp;<a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span></h4>
<div class='docblock'><p>This method tests less than (for <code>self</code> and <code>other</code>) and is used by the <code>&lt;</code> operator. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.lt">Read more</a></p>
</div><h4 id='method.le' class="method"><span id='le.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.le' class='fnname'>le</a>(&amp;self, __arg_0: &amp;<a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span></h4>
<div class='docblock'><p>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 href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.le">Read more</a></p>
</div><h4 id='method.gt' class="method"><span id='gt.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.gt' class='fnname'>gt</a>(&amp;self, __arg_0: &amp;<a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span></h4>
<div class='docblock'><p>This method tests greater than (for <code>self</code> and <code>other</code>) and is used by the <code>&gt;</code> operator. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.gt">Read more</a></p>
</div><h4 id='method.ge' class="method"><span id='ge.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.ge' class='fnname'>ge</a>(&amp;self, __arg_0: &amp;<a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span></h4>
<div class='docblock'><p>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 href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.ge">Read more</a></p>
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html" title="trait core::cmp::Ord">Ord</a> for <a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/chrono/naive/datetime.rs.html#20' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.cmp' class="method"><span id='cmp.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html#tymethod.cmp' class='fnname'>cmp</a>(&amp;self, __arg_0: &amp;<a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/cmp/enum.Ordering.html" title="enum core::cmp::Ordering">Ordering</a></code></span></h4>
<div class='docblock'><p>This method returns an <code>Ordering</code> between <code>self</code> and <code>other</code>. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html#tymethod.cmp">Read more</a></p>
</div><h4 id='method.max' class="method"><span id='max.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html#method.max' class='fnname'>max</a>(self, other: Self) -&gt; Self</code></span></h4>
<div class='stability'><div class='stab unstable'><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>ord_max_min</code>)</div></div><div class='docblock'><p>Compares and returns the maximum of two values. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html#method.max">Read more</a></p>
</div><h4 id='method.min' class="method"><span id='min.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html#method.min' class='fnname'>min</a>(self, other: Self) -&gt; Self</code></span></h4>
<div class='stability'><div class='stab unstable'><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>ord_max_min</code>)</div></div><div class='docblock'><p>Compares and returns the minimum of two values. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html#method.min">Read more</a></p>
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> for <a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/chrono/naive/datetime.rs.html#20' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'></div><h3 class='impl'><span class='in-band'><code>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> for <a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/chrono/naive/datetime.rs.html#20' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.clone' class="method"><span id='clone.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone' class='fnname'>clone</a>(&amp;self) -&gt; <a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a></code></span></h4>
<div class='docblock'><p>Returns a copy of the value. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone">Read more</a></p>
</div><h4 id='method.clone_from' class="method"><span id='clone_from.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from' class='fnname'>clone_from</a>(&amp;mut self, source: &amp;Self)</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></span></h4>
<div class='docblock'><p>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from">Read more</a></p>
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class="trait" href="../../../chrono/trait.Datelike.html" title="trait chrono::Datelike">Datelike</a> for <a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/chrono/naive/datetime.rs.html#199-515' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.year' class="method"><span id='year.v' class='invisible'><code>fn <a href='../../../chrono/trait.Datelike.html#tymethod.year' class='fnname'>year</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a></code></span></h4>
<div class='docblock'><p>Returns the year number in the <a href="./index.html#calendar-date">calendar date</a>.</p>
<p>See also the <a href="../date/struct.NaiveDate.html#method.year"><code>NaiveDate::year</code></a> method.</p>
<h1 id='example' class='section-header'><a href='#example'>Example</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">chrono</span>::{<span class="ident">NaiveDate</span>, <span class="ident">NaiveDateTime</span>, <span class="ident">Datelike</span>};
<span class="kw">let</span> <span class="ident">dt</span>: <span class="ident">NaiveDateTime</span> <span class="op">=</span> <span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">25</span>).<span class="ident">and_hms</span>(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dt</span>.<span class="ident">year</span>(), <span class="number">2015</span>);</pre>
</div><h4 id='method.month' class="method"><span id='month.v' class='invisible'><code>fn <a href='../../../chrono/trait.Datelike.html#tymethod.month' class='fnname'>month</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a></code></span></h4>
<div class='docblock'><p>Returns the month number starting from 1.</p>
<p>The return value ranges from 1 to 12.</p>
<p>See also the <a href="../date/struct.NaiveDate.html#method.month"><code>NaiveDate::month</code></a> method.</p>
<h1 id='example-1' class='section-header'><a href='#example-1'>Example</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">chrono</span>::{<span class="ident">NaiveDate</span>, <span class="ident">NaiveDateTime</span>, <span class="ident">Datelike</span>};
<span class="kw">let</span> <span class="ident">dt</span>: <span class="ident">NaiveDateTime</span> <span class="op">=</span> <span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">25</span>).<span class="ident">and_hms</span>(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dt</span>.<span class="ident">month</span>(), <span class="number">9</span>);</pre>
</div><h4 id='method.month0' class="method"><span id='month0.v' class='invisible'><code>fn <a href='../../../chrono/trait.Datelike.html#tymethod.month0' class='fnname'>month0</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a></code></span></h4>
<div class='docblock'><p>Returns the month number starting from 0.</p>
<p>The return value ranges from 0 to 11.</p>
<p>See also the <a href="../date/struct.NaiveDate.html#method.month0"><code>NaiveDate::month0</code></a> method.</p>
<h1 id='example-2' class='section-header'><a href='#example-2'>Example</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">chrono</span>::{<span class="ident">NaiveDate</span>, <span class="ident">NaiveDateTime</span>, <span class="ident">Datelike</span>};
<span class="kw">let</span> <span class="ident">dt</span>: <span class="ident">NaiveDateTime</span> <span class="op">=</span> <span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">25</span>).<span class="ident">and_hms</span>(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dt</span>.<span class="ident">month0</span>(), <span class="number">8</span>);</pre>
</div><h4 id='method.day' class="method"><span id='day.v' class='invisible'><code>fn <a href='../../../chrono/trait.Datelike.html#tymethod.day' class='fnname'>day</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a></code></span></h4>
<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>
<p>See also the <a href="../date/struct.NaiveDate.html#method.day"><code>NaiveDate::day</code></a> method.</p>
<h1 id='example-3' class='section-header'><a href='#example-3'>Example</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">chrono</span>::{<span class="ident">NaiveDate</span>, <span class="ident">NaiveDateTime</span>, <span class="ident">Datelike</span>};
<span class="kw">let</span> <span class="ident">dt</span>: <span class="ident">NaiveDateTime</span> <span class="op">=</span> <span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">25</span>).<span class="ident">and_hms</span>(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dt</span>.<span class="ident">day</span>(), <span class="number">25</span>);</pre>
</div><h4 id='method.day0' class="method"><span id='day0.v' class='invisible'><code>fn <a href='../../../chrono/trait.Datelike.html#tymethod.day0' class='fnname'>day0</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a></code></span></h4>
<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>
<p>See also the <a href="../date/struct.NaiveDate.html#method.day0"><code>NaiveDate::day0</code></a> method.</p>
<h1 id='example-4' class='section-header'><a href='#example-4'>Example</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">chrono</span>::{<span class="ident">NaiveDate</span>, <span class="ident">NaiveDateTime</span>, <span class="ident">Datelike</span>};
<span class="kw">let</span> <span class="ident">dt</span>: <span class="ident">NaiveDateTime</span> <span class="op">=</span> <span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">25</span>).<span class="ident">and_hms</span>(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dt</span>.<span class="ident">day0</span>(), <span class="number">24</span>);</pre>
</div><h4 id='method.ordinal' class="method"><span id='ordinal.v' class='invisible'><code>fn <a href='../../../chrono/trait.Datelike.html#tymethod.ordinal' class='fnname'>ordinal</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a></code></span></h4>
<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>
<p>See also the <a href="../date/struct.NaiveDate.html#method.ordinal"><code>NaiveDate::ordinal</code></a> method.</p>
<h1 id='example-5' class='section-header'><a href='#example-5'>Example</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">chrono</span>::{<span class="ident">NaiveDate</span>, <span class="ident">NaiveDateTime</span>, <span class="ident">Datelike</span>};
<span class="kw">let</span> <span class="ident">dt</span>: <span class="ident">NaiveDateTime</span> <span class="op">=</span> <span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">25</span>).<span class="ident">and_hms</span>(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dt</span>.<span class="ident">ordinal</span>(), <span class="number">268</span>);</pre>
</div><h4 id='method.ordinal0' class="method"><span id='ordinal0.v' class='invisible'><code>fn <a href='../../../chrono/trait.Datelike.html#tymethod.ordinal0' class='fnname'>ordinal0</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a></code></span></h4>
<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>
<p>See also the <a href="../date/struct.NaiveDate.html#method.ordinal0"><code>NaiveDate::ordinal0</code></a> method.</p>
<h1 id='example-6' class='section-header'><a href='#example-6'>Example</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">chrono</span>::{<span class="ident">NaiveDate</span>, <span class="ident">NaiveDateTime</span>, <span class="ident">Datelike</span>};
<span class="kw">let</span> <span class="ident">dt</span>: <span class="ident">NaiveDateTime</span> <span class="op">=</span> <span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">25</span>).<span class="ident">and_hms</span>(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dt</span>.<span class="ident">ordinal0</span>(), <span class="number">267</span>);</pre>
</div><h4 id='method.weekday' class="method"><span id='weekday.v' class='invisible'><code>fn <a href='../../../chrono/trait.Datelike.html#tymethod.weekday' class='fnname'>weekday</a>(&amp;self) -&gt; <a class="enum" href="../../../chrono/enum.Weekday.html" title="enum chrono::Weekday">Weekday</a></code></span></h4>
<div class='docblock'><p>Returns the day of week.</p>
<p>See also the <a href="../date/struct.NaiveDate.html#method.weekday"><code>NaiveDate::weekday</code></a> method.</p>
<h1 id='example-7' class='section-header'><a href='#example-7'>Example</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">chrono</span>::{<span class="ident">NaiveDate</span>, <span class="ident">NaiveDateTime</span>, <span class="ident">Datelike</span>, <span class="ident">Weekday</span>};
<span class="kw">let</span> <span class="ident">dt</span>: <span class="ident">NaiveDateTime</span> <span class="op">=</span> <span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">25</span>).<span class="ident">and_hms</span>(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dt</span>.<span class="ident">weekday</span>(), <span class="ident">Weekday</span>::<span class="ident">Fri</span>);</pre>
</div><h4 id='method.isoweekdate' class="method"><span id='isoweekdate.v' class='invisible'><code>fn <a href='../../../chrono/trait.Datelike.html#tymethod.isoweekdate' class='fnname'>isoweekdate</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, <a class="enum" href="../../../chrono/enum.Weekday.html" title="enum chrono::Weekday">Weekday</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a></code></span></h4>
<div class='docblock'><p>Returns the ISO week date: an adjusted year, week number and day of week. The adjusted year may differ from that of the calendar date. <a href="../../../chrono/trait.Datelike.html#tymethod.isoweekdate">Read more</a></p>
</div><h4 id='method.with_year' class="method"><span id='with_year.v' class='invisible'><code>fn <a href='../../../chrono/trait.Datelike.html#tymethod.with_year' class='fnname'>with_year</a>(&amp;self, year: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a>&gt;</code></span></h4>
<div class='docblock'><p>Makes a new <code>NaiveDateTime</code> with the year number changed.</p>
<p>Returns <code>None</code> when the resulting <code>NaiveDateTime</code> would be invalid.</p>
<p>See also the
<a href="../date/struct.NaiveDate.html#method.with_year"><code>NaiveDate::with_year</code></a> method.</p>
<h1 id='example-8' class='section-header'><a href='#example-8'>Example</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">chrono</span>::{<span class="ident">NaiveDate</span>, <span class="ident">NaiveDateTime</span>, <span class="ident">Datelike</span>};
<span class="kw">let</span> <span class="ident">dt</span>: <span class="ident">NaiveDateTime</span> <span class="op">=</span> <span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">25</span>).<span class="ident">and_hms</span>(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dt</span>.<span class="ident">with_year</span>(<span class="number">2016</span>), <span class="prelude-val">Some</span>(<span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="number">2016</span>, <span class="number">9</span>, <span class="number">25</span>).<span class="ident">and_hms</span>(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>)));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dt</span>.<span class="ident">with_year</span>(<span class="op">-</span><span class="number">308</span>), <span class="prelude-val">Some</span>(<span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="op">-</span><span class="number">308</span>, <span class="number">9</span>, <span class="number">25</span>).<span class="ident">and_hms</span>(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>)));</pre>
</div><h4 id='method.with_month' class="method"><span id='with_month.v' class='invisible'><code>fn <a href='../../../chrono/trait.Datelike.html#tymethod.with_month' class='fnname'>with_month</a>(&amp;self, month: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a>&gt;</code></span></h4>
<div class='docblock'><p>Makes a new <code>NaiveDateTime</code> with the month number (starting from 1) changed.</p>
<p>Returns <code>None</code> when the resulting <code>NaiveDateTime</code> would be invalid.</p>
<p>See also the
<a href="../date/struct.NaiveDate.html#method.with_month"><code>NaiveDate::with_month</code></a> method.</p>
<h1 id='example-9' class='section-header'><a href='#example-9'>Example</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">chrono</span>::{<span class="ident">NaiveDate</span>, <span class="ident">NaiveDateTime</span>, <span class="ident">Datelike</span>};
<span class="kw">let</span> <span class="ident">dt</span>: <span class="ident">NaiveDateTime</span> <span class="op">=</span> <span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">30</span>).<span class="ident">and_hms</span>(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dt</span>.<span class="ident">with_month</span>(<span class="number">10</span>), <span class="prelude-val">Some</span>(<span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="number">2015</span>, <span class="number">10</span>, <span class="number">30</span>).<span class="ident">and_hms</span>(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>)));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dt</span>.<span class="ident">with_month</span>(<span class="number">13</span>), <span class="prelude-val">None</span>); <span class="comment">// no month 13</span>
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dt</span>.<span class="ident">with_month</span>(<span class="number">2</span>), <span class="prelude-val">None</span>); <span class="comment">// no February 30</span></pre>
</div><h4 id='method.with_month0' class="method"><span id='with_month0.v' class='invisible'><code>fn <a href='../../../chrono/trait.Datelike.html#tymethod.with_month0' class='fnname'>with_month0</a>(&amp;self, month0: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a>&gt;</code></span></h4>
<div class='docblock'><p>Makes a new <code>NaiveDateTime</code> with the month number (starting from 0) changed.</p>
<p>Returns <code>None</code> when the resulting <code>NaiveDateTime</code> would be invalid.</p>
<p>See also the
<a href="../date/struct.NaiveDate.html#method.with_month0"><code>NaiveDate::with_month0</code></a> method.</p>
<h1 id='example-10' class='section-header'><a href='#example-10'>Example</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">chrono</span>::{<span class="ident">NaiveDate</span>, <span class="ident">NaiveDateTime</span>, <span class="ident">Datelike</span>};
<span class="kw">let</span> <span class="ident">dt</span>: <span class="ident">NaiveDateTime</span> <span class="op">=</span> <span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">30</span>).<span class="ident">and_hms</span>(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dt</span>.<span class="ident">with_month0</span>(<span class="number">9</span>), <span class="prelude-val">Some</span>(<span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="number">2015</span>, <span class="number">10</span>, <span class="number">30</span>).<span class="ident">and_hms</span>(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>)));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dt</span>.<span class="ident">with_month0</span>(<span class="number">12</span>), <span class="prelude-val">None</span>); <span class="comment">// no month 13</span>
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dt</span>.<span class="ident">with_month0</span>(<span class="number">1</span>), <span class="prelude-val">None</span>); <span class="comment">// no February 30</span></pre>
</div><h4 id='method.with_day' class="method"><span id='with_day.v' class='invisible'><code>fn <a href='../../../chrono/trait.Datelike.html#tymethod.with_day' class='fnname'>with_day</a>(&amp;self, day: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a>&gt;</code></span></h4>
<div class='docblock'><p>Makes a new <code>NaiveDateTime</code> with the day of month (starting from 1) changed.</p>
<p>Returns <code>None</code> when the resulting <code>NaiveDateTime</code> would be invalid.</p>
<p>See also the
<a href="../date/struct.NaiveDate.html#method.with_day"><code>NaiveDate::with_day</code></a> method.</p>
<h1 id='example-11' class='section-header'><a href='#example-11'>Example</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">chrono</span>::{<span class="ident">NaiveDate</span>, <span class="ident">NaiveDateTime</span>, <span class="ident">Datelike</span>};
<span class="kw">let</span> <span class="ident">dt</span>: <span class="ident">NaiveDateTime</span> <span class="op">=</span> <span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">8</span>).<span class="ident">and_hms</span>(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dt</span>.<span class="ident">with_day</span>(<span class="number">30</span>), <span class="prelude-val">Some</span>(<span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">30</span>).<span class="ident">and_hms</span>(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>)));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dt</span>.<span class="ident">with_day</span>(<span class="number">31</span>), <span class="prelude-val">None</span>); <span class="comment">// no September 31</span></pre>
</div><h4 id='method.with_day0' class="method"><span id='with_day0.v' class='invisible'><code>fn <a href='../../../chrono/trait.Datelike.html#tymethod.with_day0' class='fnname'>with_day0</a>(&amp;self, day0: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a>&gt;</code></span></h4>
<div class='docblock'><p>Makes a new <code>NaiveDateTime</code> with the day of month (starting from 0) changed.</p>
<p>Returns <code>None</code> when the resulting <code>NaiveDateTime</code> would be invalid.</p>
<p>See also the
<a href="../date/struct.NaiveDate.html#method.with_day0"><code>NaiveDate::with_day0</code></a> method.</p>
<h1 id='example-12' class='section-header'><a href='#example-12'>Example</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">chrono</span>::{<span class="ident">NaiveDate</span>, <span class="ident">NaiveDateTime</span>, <span class="ident">Datelike</span>};
<span class="kw">let</span> <span class="ident">dt</span>: <span class="ident">NaiveDateTime</span> <span class="op">=</span> <span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">8</span>).<span class="ident">and_hms</span>(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dt</span>.<span class="ident">with_day0</span>(<span class="number">29</span>), <span class="prelude-val">Some</span>(<span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">30</span>).<span class="ident">and_hms</span>(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>)));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dt</span>.<span class="ident">with_day0</span>(<span class="number">30</span>), <span class="prelude-val">None</span>); <span class="comment">// no September 31</span></pre>
</div><h4 id='method.with_ordinal' class="method"><span id='with_ordinal.v' class='invisible'><code>fn <a href='../../../chrono/trait.Datelike.html#tymethod.with_ordinal' class='fnname'>with_ordinal</a>(&amp;self, ordinal: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a>&gt;</code></span></h4>
<div class='docblock'><p>Makes a new <code>NaiveDateTime</code> with the day of year (starting from 1) changed.</p>
<p>Returns <code>None</code> when the resulting <code>NaiveDateTime</code> would be invalid.</p>
<p>See also the
<a href="../date/struct.NaiveDate.html#method.with_ordinal"><code>NaiveDate::with_ordinal</code></a> method.</p>
<h1 id='example-13' class='section-header'><a href='#example-13'>Example</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">chrono</span>::{<span class="ident">NaiveDate</span>, <span class="ident">NaiveDateTime</span>, <span class="ident">Datelike</span>};
<span class="kw">let</span> <span class="ident">dt</span>: <span class="ident">NaiveDateTime</span> <span class="op">=</span> <span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">8</span>).<span class="ident">and_hms</span>(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dt</span>.<span class="ident">with_ordinal</span>(<span class="number">60</span>),
<span class="prelude-val">Some</span>(<span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="number">2015</span>, <span class="number">3</span>, <span class="number">1</span>).<span class="ident">and_hms</span>(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>)));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dt</span>.<span class="ident">with_ordinal</span>(<span class="number">366</span>), <span class="prelude-val">None</span>); <span class="comment">// 2015 had only 365 days</span>
<span class="kw">let</span> <span class="ident">dt</span>: <span class="ident">NaiveDateTime</span> <span class="op">=</span> <span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="number">2016</span>, <span class="number">9</span>, <span class="number">8</span>).<span class="ident">and_hms</span>(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dt</span>.<span class="ident">with_ordinal</span>(<span class="number">60</span>),
<span class="prelude-val">Some</span>(<span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="number">2016</span>, <span class="number">2</span>, <span class="number">29</span>).<span class="ident">and_hms</span>(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>)));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dt</span>.<span class="ident">with_ordinal</span>(<span class="number">366</span>),
<span class="prelude-val">Some</span>(<span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="number">2016</span>, <span class="number">12</span>, <span class="number">31</span>).<span class="ident">and_hms</span>(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>)));</pre>
</div><h4 id='method.with_ordinal0' class="method"><span id='with_ordinal0.v' class='invisible'><code>fn <a href='../../../chrono/trait.Datelike.html#tymethod.with_ordinal0' class='fnname'>with_ordinal0</a>(&amp;self, ordinal0: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a>&gt;</code></span></h4>
<div class='docblock'><p>Makes a new <code>NaiveDateTime</code> with the day of year (starting from 0) changed.</p>
<p>Returns <code>None</code> when the resulting <code>NaiveDateTime</code> would be invalid.</p>
<p>See also the
<a href="../date/struct.NaiveDate.html#method.with_ordinal0"><code>NaiveDate::with_ordinal0</code></a> method.</p>
<h1 id='example-14' class='section-header'><a href='#example-14'>Example</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">chrono</span>::{<span class="ident">NaiveDate</span>, <span class="ident">NaiveDateTime</span>, <span class="ident">Datelike</span>};
<span class="kw">let</span> <span class="ident">dt</span>: <span class="ident">NaiveDateTime</span> <span class="op">=</span> <span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">8</span>).<span class="ident">and_hms</span>(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dt</span>.<span class="ident">with_ordinal0</span>(<span class="number">59</span>),
<span class="prelude-val">Some</span>(<span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="number">2015</span>, <span class="number">3</span>, <span class="number">1</span>).<span class="ident">and_hms</span>(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>)));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dt</span>.<span class="ident">with_ordinal0</span>(<span class="number">365</span>), <span class="prelude-val">None</span>); <span class="comment">// 2015 had only 365 days</span>
<span class="kw">let</span> <span class="ident">dt</span>: <span class="ident">NaiveDateTime</span> <span class="op">=</span> <span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="number">2016</span>, <span class="number">9</span>, <span class="number">8</span>).<span class="ident">and_hms</span>(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dt</span>.<span class="ident">with_ordinal0</span>(<span class="number">59</span>),
<span class="prelude-val">Some</span>(<span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="number">2016</span>, <span class="number">2</span>, <span class="number">29</span>).<span class="ident">and_hms</span>(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>)));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dt</span>.<span class="ident">with_ordinal0</span>(<span class="number">365</span>),
<span class="prelude-val">Some</span>(<span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="number">2016</span>, <span class="number">12</span>, <span class="number">31</span>).<span class="ident">and_hms</span>(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>)));</pre>
</div><h4 id='method.year_ce' class="method"><span id='year_ce.v' class='invisible'><code>fn <a href='../../../chrono/trait.Datelike.html#method.year_ce' class='fnname'>year_ce</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a></code></span></h4>
<div class='docblock'><p>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="../../../chrono/trait.Datelike.html#method.year_ce">Read more</a></p>
</div><h4 id='method.num_days_from_ce' class="method"><span id='num_days_from_ce.v' class='invisible'><code>fn <a href='../../../chrono/trait.Datelike.html#method.num_days_from_ce' class='fnname'>num_days_from_ce</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a></code></span></h4>
<div class='docblock'><p>Returns the number of days since January 1, 1 (Day 1) in the proleptic Gregorian calendar.</p>
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class="trait" href="../../../chrono/trait.Timelike.html" title="trait chrono::Timelike">Timelike</a> for <a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/chrono/naive/datetime.rs.html#517-683' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.hour' class="method"><span id='hour.v' class='invisible'><code>fn <a href='../../../chrono/trait.Timelike.html#tymethod.hour' class='fnname'>hour</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a></code></span></h4>
<div class='docblock'><p>Returns the hour number from 0 to 23.</p>
<p>See also the <a href="../time/struct.NaiveTime.html#method.hour"><code>NaiveTime::hour</code></a> method.</p>
<h1 id='example-15' class='section-header'><a href='#example-15'>Example</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">chrono</span>::{<span class="ident">NaiveDate</span>, <span class="ident">NaiveDateTime</span>, <span class="ident">Timelike</span>};
<span class="kw">let</span> <span class="ident">dt</span>: <span class="ident">NaiveDateTime</span> <span class="op">=</span> <span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">8</span>).<span class="ident">and_hms_milli</span>(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>, <span class="number">789</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dt</span>.<span class="ident">hour</span>(), <span class="number">12</span>);</pre>
</div><h4 id='method.minute' class="method"><span id='minute.v' class='invisible'><code>fn <a href='../../../chrono/trait.Timelike.html#tymethod.minute' class='fnname'>minute</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a></code></span></h4>
<div class='docblock'><p>Returns the minute number from 0 to 59.</p>
<p>See also the <a href="../time/struct.NaiveTime.html#method.minute"><code>NaiveTime::minute</code></a> method.</p>
<h1 id='example-16' class='section-header'><a href='#example-16'>Example</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">chrono</span>::{<span class="ident">NaiveDate</span>, <span class="ident">NaiveDateTime</span>, <span class="ident">Timelike</span>};
<span class="kw">let</span> <span class="ident">dt</span>: <span class="ident">NaiveDateTime</span> <span class="op">=</span> <span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">8</span>).<span class="ident">and_hms_milli</span>(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>, <span class="number">789</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dt</span>.<span class="ident">minute</span>(), <span class="number">34</span>);</pre>
</div><h4 id='method.second' class="method"><span id='second.v' class='invisible'><code>fn <a href='../../../chrono/trait.Timelike.html#tymethod.second' class='fnname'>second</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a></code></span></h4>
<div class='docblock'><p>Returns the second number from 0 to 59.</p>
<p>See also the <a href="../time/struct.NaiveTime.html#method.second"><code>NaiveTime::second</code></a> method.</p>
<h1 id='example-17' class='section-header'><a href='#example-17'>Example</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">chrono</span>::{<span class="ident">NaiveDate</span>, <span class="ident">NaiveDateTime</span>, <span class="ident">Timelike</span>};
<span class="kw">let</span> <span class="ident">dt</span>: <span class="ident">NaiveDateTime</span> <span class="op">=</span> <span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">8</span>).<span class="ident">and_hms_milli</span>(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>, <span class="number">789</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dt</span>.<span class="ident">second</span>(), <span class="number">56</span>);</pre>
</div><h4 id='method.nanosecond' class="method"><span id='nanosecond.v' class='invisible'><code>fn <a href='../../../chrono/trait.Timelike.html#tymethod.nanosecond' class='fnname'>nanosecond</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a></code></span></h4>
<div class='docblock'><p>Returns the number of nanoseconds since the whole non-leap second.
The range from 1,000,000,000 to 1,999,999,999 represents
the <a href="./naive/time/index.html#leap-second-handling">leap second</a>.</p>
<p>See also the
<a href="../time/struct.NaiveTime.html#method.nanosecond"><code>NaiveTime::nanosecond</code></a> method.</p>
<h1 id='example-18' class='section-header'><a href='#example-18'>Example</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">chrono</span>::{<span class="ident">NaiveDate</span>, <span class="ident">NaiveDateTime</span>, <span class="ident">Timelike</span>};
<span class="kw">let</span> <span class="ident">dt</span>: <span class="ident">NaiveDateTime</span> <span class="op">=</span> <span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">8</span>).<span class="ident">and_hms_milli</span>(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>, <span class="number">789</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dt</span>.<span class="ident">nanosecond</span>(), <span class="number">789_000_000</span>);</pre>
</div><h4 id='method.with_hour' class="method"><span id='with_hour.v' class='invisible'><code>fn <a href='../../../chrono/trait.Timelike.html#tymethod.with_hour' class='fnname'>with_hour</a>(&amp;self, hour: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a>&gt;</code></span></h4>
<div class='docblock'><p>Makes a new <code>NaiveDateTime</code> with the hour number changed.</p>
<p>Returns <code>None</code> when the resulting <code>NaiveDateTime</code> would be invalid.</p>
<p>See also the
<a href="../time/struct.NaiveTime.html#method.with_hour"><code>NaiveTime::with_hour</code></a> method.</p>
<h1 id='example-19' class='section-header'><a href='#example-19'>Example</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">chrono</span>::{<span class="ident">NaiveDate</span>, <span class="ident">NaiveDateTime</span>, <span class="ident">Timelike</span>};
<span class="kw">let</span> <span class="ident">dt</span>: <span class="ident">NaiveDateTime</span> <span class="op">=</span> <span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">8</span>).<span class="ident">and_hms_milli</span>(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>, <span class="number">789</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dt</span>.<span class="ident">with_hour</span>(<span class="number">7</span>),
<span class="prelude-val">Some</span>(<span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">8</span>).<span class="ident">and_hms_milli</span>(<span class="number">7</span>, <span class="number">34</span>, <span class="number">56</span>, <span class="number">789</span>)));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dt</span>.<span class="ident">with_hour</span>(<span class="number">24</span>), <span class="prelude-val">None</span>);</pre>
</div><h4 id='method.with_minute' class="method"><span id='with_minute.v' class='invisible'><code>fn <a href='../../../chrono/trait.Timelike.html#tymethod.with_minute' class='fnname'>with_minute</a>(&amp;self, min: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a>&gt;</code></span></h4>
<div class='docblock'><p>Makes a new <code>NaiveDateTime</code> with the minute number changed.</p>
<p>Returns <code>None</code> when the resulting <code>NaiveDateTime</code> would be invalid.</p>
<p>See also the
<a href="../time/struct.NaiveTime.html#method.with_minute"><code>NaiveTime::with_minute</code></a> method.</p>
<h1 id='example-20' class='section-header'><a href='#example-20'>Example</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">chrono</span>::{<span class="ident">NaiveDate</span>, <span class="ident">NaiveDateTime</span>, <span class="ident">Timelike</span>};
<span class="kw">let</span> <span class="ident">dt</span>: <span class="ident">NaiveDateTime</span> <span class="op">=</span> <span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">8</span>).<span class="ident">and_hms_milli</span>(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>, <span class="number">789</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dt</span>.<span class="ident">with_minute</span>(<span class="number">45</span>),
<span class="prelude-val">Some</span>(<span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">8</span>).<span class="ident">and_hms_milli</span>(<span class="number">12</span>, <span class="number">45</span>, <span class="number">56</span>, <span class="number">789</span>)));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dt</span>.<span class="ident">with_minute</span>(<span class="number">60</span>), <span class="prelude-val">None</span>);</pre>
</div><h4 id='method.with_second' class="method"><span id='with_second.v' class='invisible'><code>fn <a href='../../../chrono/trait.Timelike.html#tymethod.with_second' class='fnname'>with_second</a>(&amp;self, sec: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a>&gt;</code></span></h4>
<div class='docblock'><p>Makes a new <code>NaiveDateTime</code> with the second number changed.</p>
<p>Returns <code>None</code> when the resulting <code>NaiveDateTime</code> would be invalid.
As with the <a href="#method.second"><code>second</code></a> method,
the input range is restricted to 0 through 59.</p>
<p>See also the
<a href="../time/struct.NaiveTime.html#method.with_second"><code>NaiveTime::with_second</code></a> method.</p>
<h1 id='example-21' class='section-header'><a href='#example-21'>Example</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">chrono</span>::{<span class="ident">NaiveDate</span>, <span class="ident">NaiveDateTime</span>, <span class="ident">Timelike</span>};
<span class="kw">let</span> <span class="ident">dt</span>: <span class="ident">NaiveDateTime</span> <span class="op">=</span> <span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">8</span>).<span class="ident">and_hms_milli</span>(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>, <span class="number">789</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dt</span>.<span class="ident">with_second</span>(<span class="number">17</span>),
<span class="prelude-val">Some</span>(<span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">8</span>).<span class="ident">and_hms_milli</span>(<span class="number">12</span>, <span class="number">34</span>, <span class="number">17</span>, <span class="number">789</span>)));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dt</span>.<span class="ident">with_second</span>(<span class="number">60</span>), <span class="prelude-val">None</span>);</pre>
</div><h4 id='method.with_nanosecond' class="method"><span id='with_nanosecond.v' class='invisible'><code>fn <a href='../../../chrono/trait.Timelike.html#tymethod.with_nanosecond' class='fnname'>with_nanosecond</a>(&amp;self, nano: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a>&gt;</code></span></h4>
<div class='docblock'><p>Makes a new <code>NaiveDateTime</code> with nanoseconds since the whole non-leap second changed.</p>
<p>Returns <code>None</code> when the resulting <code>NaiveDateTime</code> would be invalid.
As with the <a href="#method.nanosecond"><code>nanosecond</code></a> method,
the input range can exceed 1,000,000,000 for leap seconds.</p>
<p>See also the
<a href="../time/struct.NaiveTime.html#method.with_nanosecond"><code>NaiveTime::with_nanosecond</code></a>
method.</p>
<h1 id='example-22' class='section-header'><a href='#example-22'>Example</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">chrono</span>::{<span class="ident">NaiveDate</span>, <span class="ident">NaiveDateTime</span>, <span class="ident">Timelike</span>};
<span class="kw">let</span> <span class="ident">dt</span>: <span class="ident">NaiveDateTime</span> <span class="op">=</span> <span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">8</span>).<span class="ident">and_hms_milli</span>(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>, <span class="number">789</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dt</span>.<span class="ident">with_nanosecond</span>(<span class="number">333_333_333</span>),
<span class="prelude-val">Some</span>(<span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">8</span>).<span class="ident">and_hms_nano</span>(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>, <span class="number">333_333_333</span>)));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dt</span>.<span class="ident">with_nanosecond</span>(<span class="number">1_333_333_333</span>), <span class="comment">// leap second</span>
<span class="prelude-val">Some</span>(<span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="number">2015</span>, <span class="number">9</span>, <span class="number">8</span>).<span class="ident">and_hms_nano</span>(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>, <span class="number">1_333_333_333</span>)));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dt</span>.<span class="ident">with_nanosecond</span>(<span class="number">2_000_000_000</span>), <span class="prelude-val">None</span>);</pre>
</div><h4 id='method.hour12' class="method"><span id='hour12.v' class='invisible'><code>fn <a href='../../../chrono/trait.Timelike.html#method.hour12' class='fnname'>hour12</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a></code></span></h4>
<div class='docblock'><p>Returns the hour number from 1 to 12 with a boolean flag, which is false for AM and true for PM. <a href="../../../chrono/trait.Timelike.html#method.hour12">Read more</a></p>
</div><h4 id='method.num_seconds_from_midnight' class="method"><span id='num_seconds_from_midnight.v' class='invisible'><code>fn <a href='../../../chrono/trait.Timelike.html#method.num_seconds_from_midnight' class='fnname'>num_seconds_from_midnight</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a></code></span></h4>
<div class='docblock'><p>Returns the number of non-leap seconds past the last midnight.</p>
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a> for <a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/chrono/naive/datetime.rs.html#689-694' title='goto source code'>[src]</a></span></h3>
<div class='docblock'><p><code>NaiveDateTime</code> can be used as a key to the hash maps (in principle).</p>
<p>Practically this also takes account of fractional seconds, so it is not recommended.
(For the obvious reason this also distinguishes leap seconds from non-leap seconds.)</p>
</div><div class='impl-items'><h4 id='method.hash' class="method"><span id='hash.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html#tymethod.hash' class='fnname'>hash</a>&lt;H:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hasher.html" title="trait core::hash::Hasher">Hasher</a>&gt;(&amp;self, state: &amp;mut H)</code></span></h4>
<div class='docblock'><p>Feeds this value into the given [<code>Hasher</code>]. <a href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html#tymethod.hash">Read more</a></p>
</div><h4 id='method.hash_slice' class="method"><span id='hash_slice.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html#method.hash_slice' class='fnname'>hash_slice</a>&lt;H&gt;(data: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[Self]</a>, state: &amp;mut H) <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;H: <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hasher.html" title="trait core::hash::Hasher">Hasher</a>,&nbsp;</span></code><div class='since' title='Stable since Rust version 1.3.0'>1.3.0</div></span></h4>
<div class='docblock'><p>Feeds a slice of this type into the given [<code>Hasher</code>]. <a href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html#method.hash_slice">Read more</a></p>
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/arith/trait.Add.html" title="trait core::ops::arith::Add">Add</a>&lt;<a class="struct" href="../../../chrono/duration/struct.Duration.html" title="struct chrono::duration::Duration">Duration</a>&gt; for <a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/chrono/naive/datetime.rs.html#696-703' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='associatedtype.Output' class="type"><span id='Output.t' class='invisible'><code>type <a href='https://doc.rust-lang.org/nightly/core/ops/arith/trait.Add.html#associatedtype.Output' class="type">Output</a> = <a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a></code></span></h4>
<div class='docblock'><p>The resulting type after applying the <code>+</code> operator</p>
</div><h4 id='method.add' class="method"><span id='add.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/ops/arith/trait.Add.html#tymethod.add' class='fnname'>add</a>(self, rhs: <a class="struct" href="../../../chrono/duration/struct.Duration.html" title="struct chrono::duration::Duration">Duration</a>) -&gt; <a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a></code></span></h4>
<div class='docblock'><p>The method for the <code>+</code> operator</p>
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/arith/trait.Sub.html" title="trait core::ops::arith::Sub">Sub</a>&lt;<a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a>&gt; for <a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/chrono/naive/datetime.rs.html#705-711' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='associatedtype.Output-1' class="type"><span id='Output.t-1' class='invisible'><code>type <a href='https://doc.rust-lang.org/nightly/core/ops/arith/trait.Sub.html#associatedtype.Output' class="type">Output</a> = <a class="struct" href="../../../chrono/duration/struct.Duration.html" title="struct chrono::duration::Duration">Duration</a></code></span></h4>
<div class='docblock'><p>The resulting type after applying the <code>-</code> operator</p>
</div><h4 id='method.sub' class="method"><span id='sub.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/ops/arith/trait.Sub.html#tymethod.sub' class='fnname'>sub</a>(self, rhs: <a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a>) -&gt; <a class="struct" href="../../../chrono/duration/struct.Duration.html" title="struct chrono::duration::Duration">Duration</a></code></span></h4>
<div class='docblock'><p>The method for the <code>-</code> operator</p>
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/arith/trait.Sub.html" title="trait core::ops::arith::Sub">Sub</a>&lt;<a class="struct" href="../../../chrono/duration/struct.Duration.html" title="struct chrono::duration::Duration">Duration</a>&gt; for <a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/chrono/naive/datetime.rs.html#713-720' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='associatedtype.Output-2' class="type"><span id='Output.t-2' class='invisible'><code>type <a href='https://doc.rust-lang.org/nightly/core/ops/arith/trait.Sub.html#associatedtype.Output' class="type">Output</a> = <a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a></code></span></h4>
<div class='docblock'><p>The resulting type after applying the <code>-</code> operator</p>
</div><h4 id='method.sub-1' class="method"><span id='sub.v-1' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/ops/arith/trait.Sub.html#tymethod.sub' class='fnname'>sub</a>(self, rhs: <a class="struct" href="../../../chrono/duration/struct.Duration.html" title="struct chrono::duration::Duration">Duration</a>) -&gt; <a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a></code></span></h4>
<div class='docblock'><p>The method for the <code>-</code> operator</p>
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/chrono/naive/datetime.rs.html#722-726' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.fmt' class="method"><span id='fmt.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt' class='fnname'>fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code></span></h4>
<div class='docblock'><p>Formats the value using the given formatter.</p>
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a> for <a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/chrono/naive/datetime.rs.html#728-732' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.fmt-1' class="method"><span id='fmt.v-1' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#tymethod.fmt' class='fnname'>fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code></span></h4>
<div class='docblock'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#tymethod.fmt">Read more</a></p>
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/str/trait.FromStr.html" title="trait core::str::FromStr">FromStr</a> for <a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/chrono/naive/datetime.rs.html#734-757' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='associatedtype.Err' class="type"><span id='Err.t' class='invisible'><code>type <a href='https://doc.rust-lang.org/nightly/core/str/trait.FromStr.html#associatedtype.Err' class="type">Err</a> = <a class="struct" href="../../../chrono/format/struct.ParseError.html" title="struct chrono::format::ParseError">ParseError</a></code></span></h4>
<div class='docblock'><p>The associated error which can be returned from parsing.</p>
</div><h4 id='method.from_str' class="method"><span id='from_str.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/str/trait.FromStr.html#tymethod.from_str' class='fnname'>from_str</a>(s: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -&gt; <a class="type" href="../../../chrono/format/type.ParseResult.html" title="type chrono::format::ParseResult">ParseResult</a>&lt;<a class="struct" href="../../../chrono/naive/datetime/struct.NaiveDateTime.html" title="struct chrono::naive::datetime::NaiveDateTime">NaiveDateTime</a>&gt;</code></span></h4>
<div class='docblock'><p>Parses a string <code>s</code> to return a value of this type. <a href="https://doc.rust-lang.org/nightly/core/str/trait.FromStr.html#tymethod.from_str">Read more</a></p>
</div></div></section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt>?</dt>
<dd>Show this help dialog</dd>
<dt>S</dt>
<dd>Focus the search field</dd>
<dt>&larrb;</dt>
<dd>Move up in search results</dd>
<dt>&rarrb;</dt>
<dd>Move down in search results</dd>
<dt>&#9166;</dt>
<dd>Go to active search result</dd>
<dt>+</dt>
<dd>Collapse/expand all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
<script>
window.rootPath = "../../../";
window.currentCrate = "chrono";
</script>
<script src="../../../main.js"></script>
<script defer src="../../../search-index.js"></script>
</body>
</html>