mentat/chrono/naive/struct.NaiveTime.html

978 lines
167 KiB
HTML
Raw Permalink Normal View History

2018-08-22 17:04:13 +00:00
<!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 `NaiveTime` struct in crate `chrono`.">
<meta name="keywords" content="rust, rustlang, rust-lang, NaiveTime">
<title>chrono::naive::NaiveTime - Rust</title>
<link rel="stylesheet" type="text/css" href="../../normalize.css">
<link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle">
<link rel="stylesheet" type="text/css" href="../../dark.css">
<link rel="stylesheet" type="text/css" href="../../main.css" id="themeStyle">
<script src="../../storage.js"></script>
</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">
<div class="sidebar-menu">&#9776;</div>
<p class='location'>Struct NaiveTime</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#methods">Methods</a><div class="sidebar-links"><a href="#method.from_hms">from_hms</a><a href="#method.from_hms_opt">from_hms_opt</a><a href="#method.from_hms_milli">from_hms_milli</a><a href="#method.from_hms_milli_opt">from_hms_milli_opt</a><a href="#method.from_hms_micro">from_hms_micro</a><a href="#method.from_hms_micro_opt">from_hms_micro_opt</a><a href="#method.from_hms_nano">from_hms_nano</a><a href="#method.from_hms_nano_opt">from_hms_nano_opt</a><a href="#method.from_num_seconds_from_midnight">from_num_seconds_from_midnight</a><a href="#method.from_num_seconds_from_midnight_opt">from_num_seconds_from_midnight_opt</a><a href="#method.parse_from_str">parse_from_str</a><a href="#method.overflowing_add_signed">overflowing_add_signed</a><a href="#method.overflowing_sub_signed">overflowing_sub_signed</a><a href="#method.signed_duration_since">signed_duration_since</a><a href="#method.format_with_items">format_with_items</a><a href="#method.format">format</a></div><a class="sidebar-title" href="#implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Add%3CFixedOffset%3E">Add&lt;FixedOffset&gt;</a><a href="#impl-Sub%3CFixedOffset%3E">Sub&lt;FixedOffset&gt;</a><a href="#impl-Serialize">Serialize</a><a href="#impl-Deserialize%3C%27de%3E">Deserialize&lt;&#39;de&gt;</a><a href="#impl-PartialEq">PartialEq</a><a href="#impl-Eq">Eq</a><a href="#impl-PartialOrd">PartialOrd</a><a href="#impl-Ord">Ord</a><a href="#impl-Copy">Copy</a><a href="#impl-Clone">Clone</a><a href="#impl-Timelike">Timelike</a><a href="#impl-Hash">Hash</a><a href="#impl-Add%3COldDuration%3E">Add&lt;OldDuration&gt;</a><a href="#impl-AddAssign%3COldDuration%3E">AddAssign&lt;OldDuration&gt;</a><a href="#impl-Sub%3COldDuration%3E">Sub&lt;OldDuration&gt;</a><a href="#impl-SubAssign%3COldDuration%3E">SubAssign&lt;OldDuration&gt;</a><a href="#impl-Sub%3CNaiveTime%3E">Sub&lt;NaiveTime&gt;</a><a href="#impl-Debug">Debug</a><a href="#impl-Display">Display</a><a href="#impl-FromStr">FromStr</a></div></div><p class='location'><a href='../index.html'>chrono</a>::<wbr><a href='index.html'>naive</a></p><script>window.sidebarCurrent = {name: 'NaiveTime', ty: 'struct', relpath: ''};</script><script defer src="sidebar-items.js"></script></div>
</nav>
<div class="theme-picker">
<button id="theme-picker" aria-label="Pick another theme!">
<img src="../../brush.svg" width="18" alt="Pick another theme!">
</button>
<div id="theme-choices"></div>
</div>
<script src="../../theme.js"></script>
<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 class="struct" href=''>NaiveTime</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/time.rs.html#175-178' title='goto source code'>[src]</a></span></h1>
<pre class='rust struct'>pub struct NaiveTime { /* fields omitted */ }</pre><div class='docblock'><p>ISO 8601 time without timezone.
Allows for the nanosecond precision and optional leap second representation.</p>
<h1 id="leap-second-handling" class="section-header"><a href="#leap-second-handling">Leap Second Handling</a></h1>
<p>Since 1960s, the manmade atomic clock has been so accurate that
it is much more accurate than Earth's own motion.
It became desirable to define the civil time in terms of the atomic clock,
but that risks the desynchronization of the civil time from Earth.
To account for this, the designers of the Coordinated Universal Time (UTC)
made that the UTC should be kept within 0.9 seconds of the observed Earth-bound time.
When the mean solar day is longer than the ideal (86,400 seconds),
the error slowly accumulates and it is necessary to add a <strong>leap second</strong>
to slow the UTC down a bit.
(We may also remove a second to speed the UTC up a bit, but it never happened.)
The leap second, if any, follows 23:59:59 of June 30 or December 31 in the UTC.</p>
<p>Fast forward to the 21st century,
we have seen 26 leap seconds from January 1972 to December 2015.
Yes, 26 seconds. Probably you can read this paragraph within 26 seconds.
But those 26 seconds, and possibly more in the future, are never predictable,
and whether to add a leap second or not is known only before 6 months.
Internet-based clocks (via NTP) do account for known leap seconds,
but the system API normally doesn't (and often can't, with no network connection)
and there is no reliable way to retrieve leap second information.</p>
<p>Chrono does not try to accurately implement leap seconds; it is impossible.
Rather, <strong>it allows for leap seconds but behaves as if there are <em>no other</em> leap seconds.</strong>
Various operations will ignore any possible leap second(s)
except when any of the operands were actually leap seconds.</p>
<p>If you cannot tolerate this behavior,
you must use a separate <code>TimeZone</code> for the International Atomic Time (TAI).
TAI is like UTC but has no leap seconds, and thus slightly differs from UTC.
Chrono does not yet provide such implementation, but it is planned.</p>
<h2 id="representing-leap-seconds" class="section-header"><a href="#representing-leap-seconds">Representing Leap Seconds</a></h2>
<p>The leap second is indicated via fractional seconds more than 1 second.
This makes possible to treat a leap second as the prior non-leap second
if you don't care about sub-second accuracy.
You should use the proper formatting to get the raw leap second.</p>
<p>All methods accepting fractional seconds will accept such values.</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">chrono</span>::{<span class="ident">NaiveDate</span>, <span class="ident">NaiveTime</span>, <span class="ident">Utc</span>, <span class="ident">TimeZone</span>};
<span class="kw">let</span> <span class="ident">t</span> <span class="op">=</span> <span class="ident">NaiveTime</span>::<span class="ident">from_hms_milli</span>(<span class="number">8</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">1_000</span>);
<span class="kw">let</span> <span class="ident">dt1</span> <span class="op">=</span> <span class="ident">NaiveDate</span>::<span class="ident">from_ymd</span>(<span class="number">2015</span>, <span class="number">7</span>, <span class="number">1</span>).<span class="ident">and_hms_micro</span>(<span class="number">8</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">1_000_000</span>);
<span class="kw">let</span> <span class="ident">dt2</span> <span class="op">=</span> <span class="ident">Utc</span>.<span class="ident">ymd</span>(<span class="number">2015</span>, <span class="number">6</span>, <span class="number">30</span>).<span class="ident">and_hms_nano</span>(<span class="number">23</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">1_000_000_000</span>);</pre>
<p>Note that the leap second can happen anytime given an appropriate time zone;
2015-07-01 01:23:60 would be a proper leap second if UTC+01:24 had existed.
Practically speaking, though, by the time of the first leap second on 1972-06-30,
every time zone offset around the world has standardized to the 5-minute alignment.</p>
<h2 id="date-and-time-arithmetics" class="section-header"><a href="#date-and-time-arithmetics">Date And Time Arithmetics</a></h2>
<p>As a concrete example, let's assume that <code>03:00:60</code> and <code>04:00:60</code> are leap seconds.
In reality, of course, leap seconds are separated by at least 6 months.
We will also use some intuitive concise notations for the explanation.</p>
<p><code>Time + Duration</code>
(short for <a href="#method.overflowing_add_signed"><code>NaiveTime::overflowing_add_signed</code></a>):</p>
<ul>
<li><code>03:00:00 + 1s = 03:00:01</code>.</li>
<li><code>03:00:59 + 60s = 03:02:00</code>.</li>
<li><code>03:00:59 + 1s = 03:01:00</code>.</li>
<li><code>03:00:60 + 1s = 03:01:00</code>.
Note that the sum is identical to the previous.</li>
<li><code>03:00:60 + 60s = 03:01:59</code>.</li>
<li><code>03:00:60 + 61s = 03:02:00</code>.</li>
<li><code>03:00:60.1 + 0.8s = 03:00:60.9</code>.</li>
</ul>
<p><code>Time - Duration</code>
(short for <a href="#method.overflowing_sub_signed"><code>NaiveTime::overflowing_sub_signed</code></a>):</p>
<ul>
<li><code>03:00:00 - 1s = 02:59:59</code>.</li>
<li><code>03:01:00 - 1s = 03:00:59</code>.</li>
<li><code>03:01:00 - 60s = 03:00:00</code>.</li>
<li><code>03:00:60 - 60s = 03:00:00</code>.
Note that the result is identical to the previous.</li>
<li><code>03:00:60.7 - 0.4s = 03:00:60.3</code>.</li>
<li><code>03:00:60.7 - 0.9s = 03:00:59.8</code>.</li>
</ul>
<p><code>Time - Time</code>
(short for <a href="#method.signed_duration_since"><code>NaiveTime::signed_duration_since</code></a>):</p>
<ul>
<li><code>04:00:00 - 03:00:00 = 3600s</code>.</li>
<li><code>03:01:00 - 03:00:00 = 60s</code>.</li>
<li><code>03:00:60 - 03:00:00 = 60s</code>.
Note that the difference is identical to the previous.</li>
<li><code>03:00:60.6 - 03:00:59.4 = 1.2s</code>.</li>
<li><code>03:01:00 - 03:00:59.8 = 0.2s</code>.</li>
<li><code>03:01:00 - 03:00:60.5 = 0.5s</code>.
Note that the difference is larger than the previous,
even though the leap second clearly follows the previous whole second.</li>
<li><code>04:00:60.9 - 03:00:60.1 = (04:00:60.9 - 04:00:00) + (04:00:00 - 03:01:00) + (03:01:00 - 03:00:60.1) = 60.9s + 3540s + 0.9s = 3601.8s</code>.</li>
</ul>
<p>In general,</p>
<ul>
<li>
<p><code>Time + Duration</code> unconditionally equals to <code>Duration + Time</code>.</p>
</li>
<li>
<p><code>Time - Duration</code> unconditionally equals to <code>Time + (-Duration)</code>.</p>
</li>
<li>
<p><code>Time1 - Time2</code> unconditionally equals to <code>-(Time2 - Time1)</code>.</p>
</li>
<li>
<p>Associativity does not generally hold, because
<code>(Time + Duration1) - Duration2</code> no longer equals to <code>Time + (Duration1 - Duration2)</code>
for two positive durations.</p>
<ul>
<li>
<p>As a special case, <code>(Time + Duration) - Duration</code> also does not equal to <code>Time</code>.</p>
</li>
<li>
<p>If you can assume that all durations have the same sign, however,
then the associativity holds:
<code>(Time + Duration1) + Duration2</code> equals to <code>Time + (Duration1 + Duration2)</code>
for two positive durations.</p>
</li>
</ul>
</li>
</ul>
<h2 id="reading-and-writing-leap-seconds" class="section-header"><a href="#reading-and-writing-leap-seconds">Reading And Writing Leap Seconds</a></h2>
<p>The &quot;typical&quot; leap seconds on the minute boundary are
correctly handled both in the formatting and parsing.
The leap second in the human-readable representation
will be represented as the second part being 60, as required by ISO 8601.</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">chrono</span>::{<span class="ident">Utc</span>, <span class="ident">TimeZone</span>};
<span class="kw">let</span> <span class="ident">dt</span> <span class="op">=</span> <span class="ident">Utc</span>.<span class="ident">ymd</span>(<span class="number">2015</span>, <span class="number">6</span>, <span class="number">30</span>).<span class="ident">and_hms_milli</span>(<span class="number">23</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">1_000</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;{:?}&quot;</span>, <span class="ident">dt</span>), <span class="string">&quot;2015-06-30T23:59:60Z&quot;</span>);</pre>
<p>There are hypothetical leap seconds not on the minute boundary
nevertheless supported by Chrono.
They are allowed for the sake of completeness and consistency;
there were several &quot;exotic&quot; time zone offsets with fractional minutes prior to UTC after all.
For such cases the human-readable representation is ambiguous
and would be read back to the next non-leap second.</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">chrono</span>::{<span class="ident">DateTime</span>, <span class="ident">Utc</span>, <span class="ident">TimeZone</span>};
<span class="kw">let</span> <span class="ident">dt</span> <span class="op">=</span> <span class="ident">Utc</span>.<span class="ident">ymd</span>(<span class="number">2015</span>, <span class="number">6</span>, <span class="number">30</span>).<span class="ident">and_hms_milli</span>(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">1_000</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;{:?}&quot;</span>, <span class="ident">dt</span>), <span class="string">&quot;2015-06-30T23:56:05Z&quot;</span>);
<span class="kw">let</span> <span class="ident">dt</span> <span class="op">=</span> <span class="ident">Utc</span>.<span class="ident">ymd</span>(<span class="number">2015</span>, <span class="number">6</span>, <span class="number">30</span>).<span class="ident">and_hms</span>(<span class="number">23</span>, <span class="number">56</span>, <span class="number">5</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;{:?}&quot;</span>, <span class="ident">dt</span>), <span class="string">&quot;2015-06-30T23:56:05Z&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">DateTime</span>::<span class="ident">parse_from_rfc3339</span>(<span class="string">&quot;2015-06-30T23:56:05Z&quot;</span>).<span class="ident">unwrap</span>(), <span class="ident">dt</span>);</pre>
<p>Since Chrono alone cannot determine any existence of leap seconds,
<strong>there is absolutely no guarantee that the leap second read has actually happened</strong>.</p>
</div>
<h2 id='methods' class='small-section-header'>
Methods<a href='#methods' class='anchor'></a>
</h2>
<h3 id='impl' class='impl'><span class='in-band'><code>impl <a class="struct" href="../../chrono/naive/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a></code><a href='#impl' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#180-777' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.from_hms' class="method"><span id='from_hms.v' class='invisible'><code>pub fn <a href='#method.from_hms' class='fnname'>from_hms</a>(hour: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, min: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, sec: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -&gt; <a class="struct" href="../../chrono/naive/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#200-202' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Makes a new <code>NaiveTime</code> from hour, minute and second.</p>
<p>No <a href="#leap-second-handling">leap second</a> is allowed here;
use <code>NaiveTime::from_hms_*</code> methods with a subsecond parameter instead.</p>
<p>Panics on invalid hour, minute and/or second.</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">NaiveTime</span>, <span class="ident">Timelike</span>};
<span class="kw">let</span> <span class="ident">t</span> <span class="op">=</span> <span class="ident">NaiveTime</span>::<span class="ident">from_hms</span>(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">t</span>.<span class="ident">hour</span>(), <span class="number">23</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">t</span>.<span class="ident">minute</span>(), <span class="number">56</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">t</span>.<span class="ident">second</span>(), <span class="number">4</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">t</span>.<span class="ident">nanosecond</span>(), <span class="number">0</span>);</pre>
</div><h4 id='method.from_hms_opt' class="method"><span id='from_hms_opt.v' class='invisible'><code>pub fn <a href='#method.from_hms_opt' class='fnname'>from_hms_opt</a>(hour: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, min: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, 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/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a>&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#225-227' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Makes a new <code>NaiveTime</code> from hour, minute and second.</p>
<p>No <a href="#leap-second-handling">leap second</a> is allowed here;
use <code>NaiveTime::from_hms_*_opt</code> methods with a subsecond parameter instead.</p>
<p>Returns <code>None</code> on invalid hour, minute and/or second.</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">NaiveTime</span>;
<span class="kw">let</span> <span class="ident">from_hms_opt</span> <span class="op">=</span> <span class="ident">NaiveTime</span>::<span class="ident">from_hms_opt</span>;
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">from_hms_opt</span>(<span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>).<span class="ident">is_some</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">from_hms_opt</span>(<span class="number">23</span>, <span class="number">59</span>, <span class="number">59</span>).<span class="ident">is_some</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">from_hms_opt</span>(<span class="number">24</span>, <span class="number">0</span>, <span class="number">0</span>).<span class="ident">is_none</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">from_hms_opt</span>(<span class="number">23</span>, <span class="number">60</span>, <span class="number">0</span>).<span class="ident">is_none</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">from_hms_opt</span>(<span class="number">23</span>, <span class="number">59</span>, <span class="number">60</span>).<span class="ident">is_none</span>());</pre>
</div><h4 id='method.from_hms_milli' class="method"><span id='from_hms_milli.v' class='invisible'><code>pub fn <a href='#method.from_hms_milli' class='fnname'>from_hms_milli</a>(hour: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, min: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, sec: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, milli: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -&gt; <a class="struct" href="../../chrono/naive/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#248-250' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Makes a new <code>NaiveTime</code> from hour, minute, second and millisecond.</p>
<p>The millisecond part can exceed 1,000
in order to represent the <a href="#leap-second-handling">leap second</a>.</p>
<p>Panics on invalid hour, minute, second and/or millisecond.</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">NaiveTime</span>, <span class="ident">Timelike</span>};
<span class="kw">let</span> <span class="ident">t</span> <span class="op">=</span> <span class="ident">NaiveTime</span>::<span class="ident">from_hms_milli</span>(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">12</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">t</span>.<span class="ident">hour</span>(), <span class="number">23</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">t</span>.<span class="ident">minute</span>(), <span class="number">56</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">t</span>.<span class="ident">second</span>(), <span class="number">4</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">t</span>.<span class="ident">nanosecond</span>(), <span class="number">12_000_000</span>);</pre>
</div><h4 id='method.from_hms_milli_opt' class="method"><span id='from_hms_milli_opt.v' class='invisible'><code>pub fn <a href='#method.from_hms_milli_opt' class='fnname'>from_hms_milli_opt</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;hour: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;min: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;sec: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;milli: <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/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a>&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#275-278' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Makes a new <code>NaiveTime</code> from hour, minute, second and millisecond.</p>
<p>The millisecond part can exceed 1,000
in order to represent the <a href="#leap-second-handling">leap second</a>.</p>
<p>Returns <code>None</code> on invalid hour, minute, second and/or millisecond.</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">NaiveTime</span>;
<span class="kw">let</span> <span class="ident">from_hmsm_opt</span> <span class="op">=</span> <span class="ident">NaiveTime</span>::<span class="ident">from_hms_milli_opt</span>;
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">from_hmsm_opt</span>(<span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>).<span class="ident">is_some</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">from_hmsm_opt</span>(<span class="number">23</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">999</span>).<span class="ident">is_some</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">from_hmsm_opt</span>(<span class="number">23</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">1_999</span>).<span class="ident">is_some</span>()); <span class="comment">// a leap second after 23:59:59</span>
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">from_hmsm_opt</span>(<span class="number">24</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>).<span class="ident">is_none</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">from_hmsm_opt</span>(<span class="number">23</span>, <span class="number">60</span>, <span class="number">0</span>, <span class="number">0</span>).<span class="ident">is_none</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">from_hmsm_opt</span>(<span class="number">23</span>, <span class="number">59</span>, <span class="number">60</span>, <span class="number">0</span>).<span class="ident">is_none</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">from_hmsm_opt</span>(<span class="number">23</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">2_000</span>).<span class="ident">is_none</span>());</pre>
</div><h4 id='method.from_hms_micro' class="method"><span id='from_hms_micro.v' class='invisible'><code>pub fn <a href='#method.from_hms_micro' class='fnname'>from_hms_micro</a>(hour: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, min: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, sec: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, micro: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -&gt; <a class="struct" href="../../chrono/naive/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#299-301' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Makes a new <code>NaiveTime</code> from hour, minute, second and microsecond.</p>
<p>The microsecond part can exceed 1,000,000
in order to represent the <a href="#leap-second-handling">leap second</a>.</p>
<p>Panics on invalid hour, minute, second and/or microsecond.</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">NaiveTime</span>, <span class="ident">Timelike</span>};
<span class="kw">let</span> <span class="ident">t</span> <span class="op">=</span> <span class="ident">NaiveTime</span>::<span class="ident">from_hms_micro</span>(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">12_345</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">t</span>.<span class="ident">hour</span>(), <span class="number">23</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">t</span>.<span class="ident">minute</span>(), <span class="number">56</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">t</span>.<span class="ident">second</span>(), <span class="number">4</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">t</span>.<span class="ident">nanosecond</span>(), <span class="number">12_345_000</span>);</pre>
</div><h4 id='method.from_hms_micro_opt' class="method"><span id='from_hms_micro_opt.v' class='invisible'><code>pub fn <a href='#method.from_hms_micro_opt' class='fnname'>from_hms_micro_opt</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;hour: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;min: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;sec: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;micro: <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/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a>&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#326-329' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Makes a new <code>NaiveTime</code> from hour, minute, second and microsecond.</p>
<p>The microsecond part can exceed 1,000,000
in order to represent the <a href="#leap-second-handling">leap second</a>.</p>
<p>Returns <code>None</code> on invalid hour, minute, second and/or microsecond.</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">NaiveTime</span>;
<span class="kw">let</span> <span class="ident">from_hmsu_opt</span> <span class="op">=</span> <span class="ident">NaiveTime</span>::<span class="ident">from_hms_micro_opt</span>;
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">from_hmsu_opt</span>(<span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>).<span class="ident">is_some</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">from_hmsu_opt</span>(<span class="number">23</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">999_999</span>).<span class="ident">is_some</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">from_hmsu_opt</span>(<span class="number">23</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">1_999_999</span>).<span class="ident">is_some</span>()); <span class="comment">// a leap second after 23:59:59</span>
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">from_hmsu_opt</span>(<span class="number">24</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>).<span class="ident">is_none</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">from_hmsu_opt</span>(<span class="number">23</span>, <span class="number">60</span>, <span class="number">0</span>, <span class="number">0</span>).<span class="ident">is_none</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">from_hmsu_opt</span>(<span class="number">23</span>, <span class="number">59</span>, <span class="number">60</span>, <span class="number">0</span>).<span class="ident">is_none</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">from_hmsu_opt</span>(<span class="number">23</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">2_000_000</span>).<span class="ident">is_none</span>());</pre>
</div><h4 id='method.from_hms_nano' class="method"><span id='from_hms_nano.v' class='invisible'><code>pub fn <a href='#method.from_hms_nano' class='fnname'>from_hms_nano</a>(hour: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, min: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, sec: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, nano: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -&gt; <a class="struct" href="../../chrono/naive/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#350-352' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Makes a new <code>NaiveTime</code> from hour, minute, second and nanosecond.</p>
<p>The nanosecond part can exceed 1,000,000,000
in order to represent the <a href="#leap-second-handling">leap second</a>.</p>
<p>Panics on invalid hour, minute, second and/or nanosecond.</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">NaiveTime</span>, <span class="ident">Timelike</span>};
<span class="kw">let</span> <span class="ident">t</span> <span class="op">=</span> <span class="ident">NaiveTime</span>::<span class="ident">from_hms_nano</span>(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">12_345_678</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">t</span>.<span class="ident">hour</span>(), <span class="number">23</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">t</span>.<span class="ident">minute</span>(), <span class="number">56</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">t</span>.<span class="ident">second</span>(), <span class="number">4</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">t</span>.<span class="ident">nanosecond</span>(), <span class="number">12_345_678</span>);</pre>
</div><h4 id='method.from_hms_nano_opt' class="method"><span id='from_hms_nano_opt.v' class='invisible'><code>pub fn <a href='#method.from_hms_nano_opt' class='fnname'>from_hms_nano_opt</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;hour: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;min: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;sec: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;nano: <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/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a>&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#377-381' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Makes a new <code>NaiveTime</code> from hour, minute, second and nanosecond.</p>
<p>The nanosecond part can exceed 1,000,000,000
in order to represent the <a href="#leap-second-handling">leap second</a>.</p>
<p>Returns <code>None</code> on invalid hour, minute, second and/or nanosecond.</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">NaiveTime</span>;
<span class="kw">let</span> <span class="ident">from_hmsn_opt</span> <span class="op">=</span> <span class="ident">NaiveTime</span>::<span class="ident">from_hms_nano_opt</span>;
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">from_hmsn_opt</span>(<span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>).<span class="ident">is_some</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">from_hmsn_opt</span>(<span class="number">23</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">999_999_999</span>).<span class="ident">is_some</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">from_hmsn_opt</span>(<span class="number">23</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">1_999_999_999</span>).<span class="ident">is_some</span>()); <span class="comment">// a leap second after 23:59:59</span>
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">from_hmsn_opt</span>(<span class="number">24</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>).<span class="ident">is_none</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">from_hmsn_opt</span>(<span class="number">23</span>, <span class="number">60</span>, <span class="number">0</span>, <span class="number">0</span>).<span class="ident">is_none</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">from_hmsn_opt</span>(<span class="number">23</span>, <span class="number">59</span>, <span class="number">60</span>, <span class="number">0</span>).<span class="ident">is_none</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">from_hmsn_opt</span>(<span class="number">23</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">2_000_000_000</span>).<span class="ident">is_none</span>());</pre>
</div><h4 id='method.from_num_seconds_from_midnight' class="method"><span id='from_num_seconds_from_midnight.v' class='invisible'><code>pub fn <a href='#method.from_num_seconds_from_midnight' class='fnname'>from_num_seconds_from_midnight</a>(secs: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, nano: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -&gt; <a class="struct" href="../../chrono/naive/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#402-404' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Makes a new <code>NaiveTime</code> from the number of seconds since midnight and nanosecond.</p>
<p>The nanosecond part can exceed 1,000,000,000
in order to represent the <a href="#leap-second-handling">leap second</a>.</p>
<p>Panics on invalid number of seconds and/or nanosecond.</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">NaiveTime</span>, <span class="ident">Timelike</span>};
<span class="kw">let</span> <span class="ident">t</span> <span class="op">=</span> <span class="ident">NaiveTime</span>::<span class="ident">from_num_seconds_from_midnight</span>(<span class="number">86164</span>, <span class="number">12_345_678</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">t</span>.<span class="ident">hour</span>(), <span class="number">23</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">t</span>.<span class="ident">minute</span>(), <span class="number">56</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">t</span>.<span class="ident">second</span>(), <span class="number">4</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">t</span>.<span class="ident">nanosecond</span>(), <span class="number">12_345_678</span>);</pre>
</div><h4 id='method.from_num_seconds_from_midnight_opt' class="method"><span id='from_num_seconds_from_midnight_opt.v' class='invisible'><code>pub fn <a href='#method.from_num_seconds_from_midnight_opt' class='fnname'>from_num_seconds_from_midnight_opt</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;secs: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;nano: <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/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a>&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#427-430' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Makes a new <code>NaiveTime</code> from the number of seconds since midnight and nanosecond.</p>
<p>The nanosecond part can exceed 1,000,000,000
in order to represent the <a href="#leap-second-handling">leap second</a>.</p>
<p>Returns <code>None</code> on invalid number of seconds and/or nanosecond.</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">NaiveTime</span>;
<span class="kw">let</span> <span class="ident">from_nsecs_opt</span> <span class="op">=</span> <span class="ident">NaiveTime</span>::<span class="ident">from_num_seconds_from_midnight_opt</span>;
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">from_nsecs_opt</span>(<span class="number">0</span>, <span class="number">0</span>).<span class="ident">is_some</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">from_nsecs_opt</span>(<span class="number">86399</span>, <span class="number">999_999_999</span>).<span class="ident">is_some</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">from_nsecs_opt</span>(<span class="number">86399</span>, <span class="number">1_999_999_999</span>).<span class="ident">is_some</span>()); <span class="comment">// a leap second after 23:59:59</span>
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">from_nsecs_opt</span>(<span class="number">86_400</span>, <span class="number">0</span>).<span class="ident">is_none</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">from_nsecs_opt</span>(<span class="number">86399</span>, <span class="number">2_000_000_000</span>).<span class="ident">is_none</span>());</pre>
</div><h4 id='method.parse_from_str' class="method"><span id='parse_from_str.v' class='invisible'><code>pub 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/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a>&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#493-497' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Parses a string with the specified format string and returns a new <code>NaiveTime</code>.
See the <a href="../format/strftime/index.html"><code>format::strftime</code> module</a>
on the supported escape sequences.</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">NaiveTime</span>;
<span class="kw">let</span> <span class="ident">parse_from_str</span> <span class="op">=</span> <span class="ident">NaiveTime</span>::<span class="ident">parse_from_str</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">parse_from_str</span>(<span class="string">&quot;23:56:04&quot;</span>, <span class="string">&quot;%H:%M:%S&quot;</span>),
<span class="prelude-val">Ok</span>(<span class="ident">NaiveTime</span>::<span class="ident">from_hms</span>(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>)));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">parse_from_str</span>(<span class="string">&quot;pm012345.6789&quot;</span>, <span class="string">&quot;%p%I%M%S%.f&quot;</span>),
<span class="prelude-val">Ok</span>(<span class="ident">NaiveTime</span>::<span class="ident">from_hms_micro</span>(<span class="number">13</span>, <span class="number">23</span>, <span class="number">45</span>, <span class="number">678_900</span>)));</pre>
<p>Date and offset is ignored for the purpose of parsing.</p>
<pre class="rust rust-example-rendered">
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">parse_from_str</span>(<span class="string">&quot;2014-5-17T12:34:56+09:30&quot;</span>, <span class="string">&quot;%Y-%m-%dT%H:%M:%S%z&quot;</span>),
<span class="prelude-val">Ok</span>(<span class="ident">NaiveTime</span>::<span class="ident">from_hms</span>(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>)));</pre>
<p><a href="#leap-second-handling">Leap seconds</a> are correctly handled by
treating any time of the form <code>hh:mm:60</code> as a leap second.
(This equally applies to the formatting, so the round trip is possible.)</p>
<pre class="rust rust-example-rendered">
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">parse_from_str</span>(<span class="string">&quot;08:59:60.123&quot;</span>, <span class="string">&quot;%H:%M:%S%.f&quot;</span>),
<span class="prelude-val">Ok</span>(<span class="ident">NaiveTime</span>::<span class="ident">from_hms_milli</span>(<span class="number">8</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">1_123</span>)));</pre>
<p>Missing seconds are assumed to be zero,
but out-of-bound times or insufficient fields are errors otherwise.</p>
<pre class="rust rust-example-rendered">
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">parse_from_str</span>(<span class="string">&quot;7:15&quot;</span>, <span class="string">&quot;%H:%M&quot;</span>),
<span class="prelude-val">Ok</span>(<span class="ident">NaiveTime</span>::<span class="ident">from_hms</span>(<span class="number">7</span>, <span class="number">15</span>, <span class="number">0</span>)));
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">parse_from_str</span>(<span class="string">&quot;04m33s&quot;</span>, <span class="string">&quot;%Mm%Ss&quot;</span>).<span class="ident">is_err</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">parse_from_str</span>(<span class="string">&quot;12&quot;</span>, <span class="string">&quot;%H&quot;</span>).<span class="ident">is_err</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">parse_from_str</span>(<span class="string">&quot;17:60&quot;</span>, <span class="string">&quot;%H:%M&quot;</span>).<span class="ident">is_err</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">parse_from_str</span>(<span class="string">&quot;24:00:00&quot;</span>, <span class="string">&quot;%H:%M:%S&quot;</span>).<span class="ident">is_err</span>());</pre>
<p>All parsed fields should be consistent to each other, otherwise it's an error.
Here <code>%H</code> is for 24-hour clocks, unlike <code>%I</code>,
and thus can be independently determined without AM/PM.</p>
<pre class="rust rust-example-rendered">
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">parse_from_str</span>(<span class="string">&quot;13:07 AM&quot;</span>, <span class="string">&quot;%H:%M %p&quot;</span>).<span class="ident">is_err</span>());</pre>
</div><h4 id='method.overflowing_add_signed' class="method"><span id='overflowing_add_signed.v' class='invisible'><code>pub fn <a href='#method.overflowing_add_signed' class='fnname'>overflowing_add_signed</a>(&amp;self, rhs: <a class="struct" href="../../chrono/struct.Duration.html" title="struct chrono::Duration">OldDuration</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="struct" href="../../chrono/naive/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#522-583' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Adds given <code>Duration</code> to the current time,
and also returns the number of <em>seconds</em>
in the integral number of days ignored from the addition.
(We cannot return <code>Duration</code> because it is subject to overflow or underflow.)</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">NaiveTime</span>;
<span class="kw">use</span> <span class="ident">time</span>::<span class="ident">Duration</span>;
<span class="kw">let</span> <span class="ident">from_hms</span> <span class="op">=</span> <span class="ident">NaiveTime</span>::<span class="ident">from_hms</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">from_hms</span>(<span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>).<span class="ident">overflowing_add_signed</span>(<span class="ident">Duration</span>::<span class="ident">hours</span>(<span class="number">11</span>)),
(<span class="ident">from_hms</span>(<span class="number">14</span>, <span class="number">4</span>, <span class="number">5</span>), <span class="number">0</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">from_hms</span>(<span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>).<span class="ident">overflowing_add_signed</span>(<span class="ident">Duration</span>::<span class="ident">hours</span>(<span class="number">23</span>)),
(<span class="ident">from_hms</span>(<span class="number">2</span>, <span class="number">4</span>, <span class="number">5</span>), <span class="number">86_400</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">from_hms</span>(<span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>).<span class="ident">overflowing_add_signed</span>(<span class="ident">Duration</span>::<span class="ident">hours</span>(<span class="op">-</span><span class="number">7</span>)),
(<span class="ident">from_hms</span>(<span class="number">20</span>, <span class="number">4</span>, <span class="number">5</span>), <span class="op">-</span><span class="number">86_400</span>));</pre>
</div><h4 id='method.overflowing_sub_signed' class="method"><span id='overflowing_sub_signed.v' class='invisible'><code>pub fn <a href='#method.overflowing_sub_signed' class='fnname'>overflowing_sub_signed</a>(&amp;self, rhs: <a class="struct" href="../../chrono/struct.Duration.html" title="struct chrono::Duration">OldDuration</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="struct" href="../../chrono/naive/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#608-611' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Subtracts given <code>Duration</code> from the current time,
and also returns the number of <em>seconds</em>
in the integral number of days ignored from the subtraction.
(We cannot return <code>Duration</code> because it is subject to overflow or underflow.)</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">NaiveTime</span>;
<span class="kw">use</span> <span class="ident">time</span>::<span class="ident">Duration</span>;
<span class="kw">let</span> <span class="ident">from_hms</span> <span class="op">=</span> <span class="ident">NaiveTime</span>::<span class="ident">from_hms</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">from_hms</span>(<span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>).<span class="ident">overflowing_sub_signed</span>(<span class="ident">Duration</span>::<span class="ident">hours</span>(<span class="number">2</span>)),
(<span class="ident">from_hms</span>(<span class="number">1</span>, <span class="number">4</span>, <span class="number">5</span>), <span class="number">0</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">from_hms</span>(<span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>).<span class="ident">overflowing_sub_signed</span>(<span class="ident">Duration</span>::<span class="ident">hours</span>(<span class="number">17</span>)),
(<span class="ident">from_hms</span>(<span class="number">10</span>, <span class="number">4</span>, <span class="number">5</span>), <span class="number">86_400</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">from_hms</span>(<span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>).<span class="ident">overflowing_sub_signed</span>(<span class="ident">Duration</span>::<span class="ident">hours</span>(<span class="op">-</span><span class="number">22</span>)),
(<span class="ident">from_hms</span>(<span class="number">1</span>, <span class="number">4</span>, <span class="number">5</span>), <span class="op">-</span><span class="number">86_400</span>));</pre>
</div><h4 id='method.signed_duration_since' class="method"><span id='signed_duration_since.v' class='invisible'><code>pub fn <a href='#method.signed_duration_since' class='fnname'>signed_duration_since</a>(self, rhs: <a class="struct" href="../../chrono/naive/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a>) -&gt; <a class="struct" href="../../chrono/struct.Duration.html" title="struct chrono::Duration">OldDuration</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#673-697' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Subtracts another <code>NaiveTime</code> from the current time.
Returns a <code>Duration</code> within +/- 1 day.
This does not overflow or underflow at all.</p>
<p>As a part of Chrono's <a href="#leap-second-handling">leap second handling</a>,
the subtraction assumes that <strong>there is no leap second ever</strong>,
except when any of the <code>NaiveTime</code>s themselves represents a leap second
in which case the assumption becomes that
<strong>there are exactly one (or two) leap second(s) ever</strong>.</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">NaiveTime</span>;
<span class="kw">use</span> <span class="ident">time</span>::<span class="ident">Duration</span>;
<span class="kw">let</span> <span class="ident">from_hmsm</span> <span class="op">=</span> <span class="ident">NaiveTime</span>::<span class="ident">from_hms_milli</span>;
<span class="kw">let</span> <span class="ident">since</span> <span class="op">=</span> <span class="ident">NaiveTime</span>::<span class="ident">signed_duration_since</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">since</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>), <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>)),
<span class="ident">Duration</span>::<span class="ident">zero</span>());
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">since</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>), <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">875</span>)),
<span class="ident">Duration</span>::<span class="ident">milliseconds</span>(<span class="number">25</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">since</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>), <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">925</span>)),
<span class="ident">Duration</span>::<span class="ident">milliseconds</span>(<span class="number">975</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">since</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>), <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">0</span>, <span class="number">900</span>)),
<span class="ident">Duration</span>::<span class="ident">seconds</span>(<span class="number">7</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">since</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>), <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">0</span>, <span class="number">7</span>, <span class="number">900</span>)),
<span class="ident">Duration</span>::<span class="ident">seconds</span>(<span class="number">5</span> <span class="op">*</span> <span class="number">60</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">since</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>), <span class="ident">from_hmsm</span>(<span class="number">0</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>)),
<span class="ident">Duration</span>::<span class="ident">seconds</span>(<span class="number">3</span> <span class="op">*</span> <span class="number">3600</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">since</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>), <span class="ident">from_hmsm</span>(<span class="number">4</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>)),
<span class="ident">Duration</span>::<span class="ident">seconds</span>(<span class="op">-</span><span class="number">3600</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">since</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>), <span class="ident">from_hmsm</span>(<span class="number">2</span>, <span class="number">4</span>, <span class="number">6</span>, <span class="number">800</span>)),
<span class="ident">Duration</span>::<span class="ident">seconds</span>(<span class="number">3600</span> <span class="op">+</span> <span class="number">60</span> <span class="op">+</span> <span class="number">1</span>) <span class="op">+</span> <span class="ident">Duration</span>::<span class="ident">milliseconds</span>(<span class="number">100</span>));</pre>
<p>Leap seconds are handled, but the subtraction assumes that
there were no other leap seconds happened.</p>
<pre class="rust rust-example-rendered">
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">since</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">0</span>, <span class="number">59</span>, <span class="number">1_000</span>), <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">0</span>, <span class="number">59</span>, <span class="number">0</span>)),
<span class="ident">Duration</span>::<span class="ident">seconds</span>(<span class="number">1</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">since</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">0</span>, <span class="number">59</span>, <span class="number">1_500</span>), <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">0</span>, <span class="number">59</span>, <span class="number">0</span>)),
<span class="ident">Duration</span>::<span class="ident">milliseconds</span>(<span class="number">1500</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">since</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">0</span>, <span class="number">59</span>, <span class="number">1_000</span>), <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>)),
<span class="ident">Duration</span>::<span class="ident">seconds</span>(<span class="number">60</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">since</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>), <span class="ident">from_hmsm</span>(<span class="number">2</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">1_000</span>)),
<span class="ident">Duration</span>::<span class="ident">seconds</span>(<span class="number">1</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">since</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">0</span>, <span class="number">59</span>, <span class="number">1_000</span>), <span class="ident">from_hmsm</span>(<span class="number">2</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">1_000</span>)),
<span class="ident">Duration</span>::<span class="ident">seconds</span>(<span class="number">61</span>));</pre>
</div><h4 id='method.format_with_items' class="method"><span id='format_with_items.v' class='invisible'><code>pub 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><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#727-730' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Formats the time with the specified formatting items.
Otherwise it is same to the ordinary <a href="#method.format"><code>format</code></a> method.</p>
<p>The <code>Iterator</code> of items should be <code>Clone</code>able,
since the resulting <code>DelayedFormat</code> value may be formatted multiple times.</p>
<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">NaiveTime</span>;
<span class="kw">use</span> <span class="ident">chrono</span>::<span class="ident">format</span>::<span class="ident">strftime</span>::<span class="ident">StrftimeItems</span>;
<span class="kw">let</span> <span class="ident">fmt</span> <span class="op">=</span> <span class="ident">StrftimeItems</span>::<span class="ident">new</span>(<span class="string">&quot;%H:%M:%S&quot;</span>);
<span class="kw">let</span> <span class="ident">t</span> <span class="op">=</span> <span class="ident">NaiveTime</span>::<span class="ident">from_hms</span>(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">t</span>.<span class="ident">format_with_items</span>(<span class="ident">fmt</span>.<span class="ident">clone</span>()).<span class="ident">to_string</span>(), <span class="string">&quot;23:56:04&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">t</span>.<span class="ident">format</span>(<span class="string">&quot;%H:%M:%S&quot;</span>).<span class="ident">to_string</span>(), <span class="string">&quot;23:56:04&quot;</span>);</pre>
<p>The resulting <code>DelayedFormat</code> can be formatted directly via the <code>Display</code> trait.</p>
<pre class="rust rust-example-rendered">
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;{}&quot;</span>, <span class="ident">t</span>.<span class="ident">format_with_items</span>(<span class="ident">fmt</span>)), <span class="string">&quot;23:56:04&quot;</span>);</pre>
</div><h4 id='method.format' class="method"><span id='format.v' class='invisible'><code>pub 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><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#767-769' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Formats the 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>
<p>This returns a <code>DelayedFormat</code>,
which gets converted to a string only when actual formatting happens.
You may use the <code>to_string</code> method to get a <code>String</code>,
or just feed it into <code>print!</code> and other formatting macros.
(In this way it avoids the redundant memory allocation.)</p>
<p>A wrong format string does <em>not</em> issue an error immediately.
Rather, converting or formatting the <code>DelayedFormat</code> fails.
You are recommended to immediately use <code>DelayedFormat</code> for this reason.</p>
<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">NaiveTime</span>;
<span class="kw">let</span> <span class="ident">t</span> <span class="op">=</span> <span class="ident">NaiveTime</span>::<span class="ident">from_hms_nano</span>(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">12_345_678</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">t</span>.<span class="ident">format</span>(<span class="string">&quot;%H:%M:%S&quot;</span>).<span class="ident">to_string</span>(), <span class="string">&quot;23:56:04&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">t</span>.<span class="ident">format</span>(<span class="string">&quot;%H:%M:%S%.6f&quot;</span>).<span class="ident">to_string</span>(), <span class="string">&quot;23:56:04.012345&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">t</span>.<span class="ident">format</span>(<span class="string">&quot;%-I:%M %p&quot;</span>).<span class="ident">to_string</span>(), <span class="string">&quot;11:56 PM&quot;</span>);</pre>
<p>The resulting <code>DelayedFormat</code> can be formatted directly via the <code>Display</code> trait.</p>
<pre class="rust rust-example-rendered">
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;{}&quot;</span>, <span class="ident">t</span>.<span class="ident">format</span>(<span class="string">&quot;%H:%M:%S&quot;</span>)), <span class="string">&quot;23:56:04&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;{}&quot;</span>, <span class="ident">t</span>.<span class="ident">format</span>(<span class="string">&quot;%H:%M:%S%.6f&quot;</span>)), <span class="string">&quot;23:56:04.012345&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;{}&quot;</span>, <span class="ident">t</span>.<span class="ident">format</span>(<span class="string">&quot;%-I:%M %p&quot;</span>)), <span class="string">&quot;11:56 PM&quot;</span>);</pre>
</div></div>
<h2 id='implementations' class='small-section-header'>
Trait Implementations<a href='#implementations' class='anchor'></a>
</h2>
<h3 id='impl-Add%3CFixedOffset%3E' 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/offset/struct.FixedOffset.html" title="struct chrono::offset::FixedOffset">FixedOffset</a>&gt; for <a class="struct" href="../../chrono/naive/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a></code><a href='#impl-Add%3CFixedOffset%3E' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/offset/fixed.rs.html#151-158' 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/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</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/offset/struct.FixedOffset.html" title="struct chrono::offset::FixedOffset">FixedOffset</a>) -&gt; <a class="struct" href="../../chrono/naive/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/offset/fixed.rs.html#155-157' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Performs the <code>+</code> operation.</p>
</div></div><h3 id='impl-Sub%3CFixedOffset%3E' 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/offset/struct.FixedOffset.html" title="struct chrono::offset::FixedOffset">FixedOffset</a>&gt; for <a class="struct" href="../../chrono/naive/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a></code><a href='#impl-Sub%3CFixedOffset%3E' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/offset/fixed.rs.html#160-167' 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/naive/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</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/offset/struct.FixedOffset.html" title="struct chrono::offset::FixedOffset">FixedOffset</a>) -&gt; <a class="struct" href="../../chrono/naive/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/offset/fixed.rs.html#164-166' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Performs the <code>-</code> operation.</p>
</div></div><h3 id='impl-Serialize' class='impl'><span class='in-band'><code>impl <a class="trait" href="../../serde/ser/trait.Serialize.html" title="trait serde::ser::Serialize">Serialize</a> for <a class="struct" href="../../chrono/naive/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a></code><a href='#impl-Serialize' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#1421-1427' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.serialize' class="method"><span id='serialize.v' class='invisible'><code>fn <a href='../../serde/ser/trait.Serialize.html#tymethod.serialize' class='fnname'>serialize</a>&lt;S&gt;(&amp;self, serializer: S) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;S::<a class="type" href="../../serde/ser/trait.Serializer.html#associatedtype.Ok" title="type serde::ser::Serializer::Ok">Ok</a>, S::<a class="type" href="../../serde/ser/trait.Serializer.html#associatedtype.Error" title="type serde::ser::Serializer::Error">Error</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;S: <a class="trait" href="../../serde/ser/trait.Serializer.html" title="trait serde::ser::Serializer">Serializer</a>,&nbsp;</span></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#1422-1426' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Serialize this value into the given Serde serializer. <a href="../../serde/ser/trait.Serialize.html#tymethod.serialize">Read more</a></p>
</div></div><h3 id='impl-Deserialize%3C%27de%3E' class='impl'><span class='in-band'><code>impl&lt;'de&gt; <a class="trait" href="../../serde/de/trait.Deserialize.html" title="trait serde::de::Deserialize">Deserialize</a>&lt;'de&gt; for <a class="struct" href="../../chrono/naive/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a></code><a href='#impl-Deserialize%3C%27de%3E' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#1446-1452' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.deserialize' class="method"><span id='deserialize.v' class='invisible'><code>fn <a href='../../serde/de/trait.Deserialize.html#tymethod.deserialize' class='fnname'>deserialize</a>&lt;D&gt;(deserializer: D) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self, D::<a class="type" href="../../serde/de/trait.Deserializer.html#associatedtype.Error" title="type serde::de::Deserializer::Error">Error</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;D: <a class="trait" href="../../serde/de/trait.Deserializer.html" title="trait serde::de::Deserializer">Deserializer</a>&lt;'de&gt;,&nbsp;</span></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#1447-1451' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Deserialize this value from the given Serde deserializer. <a href="../../serde/de/trait.Deserialize.html#tymethod.deserialize">Read more</a></p>
</div></div><h3 id='impl-PartialEq' 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/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a></code><a href='#impl-PartialEq' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#174' 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/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#174' title='goto source code'>[src]</a></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/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#174' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>This method tests for <code>!=</code>.</p>
</div></div><h3 id='impl-Eq' 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/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a></code><a href='#impl-Eq' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#174' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'></div><h3 id='impl-PartialOrd' 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/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a></code><a href='#impl-PartialOrd' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#174' 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/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</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><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#174' title='goto source code'>[src]</a></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/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#174' title='goto source code'>[src]</a></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/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#174' title='goto source code'>[src]</a></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/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#174' title='goto source code'>[src]</a></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/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#174' title='goto source code'>[src]</a></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 id='impl-Ord' 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/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a></code><a href='#impl-Ord' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#174' 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/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</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><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#174' title='goto source code'>[src]</a></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><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.21.0'>1.21.0</div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/cmp.rs.html#460-463' title='goto source code'>[src]</a></span></h4>
<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><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.21.0'>1.21.0</div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/cmp.rs.html#476-479' title='goto source code'>[src]</a></span></h4>
<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 id='impl-Copy' 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/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a></code><a href='#impl-Copy' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#174' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'></div><h3 id='impl-Clone' 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/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a></code><a href='#impl-Clone' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#174' 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/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#174' title='goto source code'>[src]</a></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: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>Self)</code></span><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/clone.rs.html#112-114' title='goto source code'>[src]</a></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 id='impl-Timelike' 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/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a></code><a href='#impl-Timelike' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#779-978' 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><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#791-793' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Returns the hour number from 0 to 23.</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">NaiveTime</span>, <span class="ident">Timelike</span>};
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">NaiveTime</span>::<span class="ident">from_hms</span>(<span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>).<span class="ident">hour</span>(), <span class="number">0</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">NaiveTime</span>::<span class="ident">from_hms_nano</span>(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">12_345_678</span>).<span class="ident">hour</span>(), <span class="number">23</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><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#806-808' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Returns the minute number from 0 to 59.</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">NaiveTime</span>, <span class="ident">Timelike</span>};
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">NaiveTime</span>::<span class="ident">from_hms</span>(<span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>).<span class="ident">minute</span>(), <span class="number">0</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">NaiveTime</span>::<span class="ident">from_hms_nano</span>(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">12_345_678</span>).<span class="ident">minute</span>(), <span class="number">56</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><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#832-834' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Returns the second number from 0 to 59.</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">NaiveTime</span>, <span class="ident">Timelike</span>};
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">NaiveTime</span>::<span class="ident">from_hms</span>(<span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>).<span class="ident">second</span>(), <span class="number">0</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">NaiveTime</span>::<span class="ident">from_hms_nano</span>(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">12_345_678</span>).<span class="ident">second</span>(), <span class="number">4</span>);</pre>
<p>This method never returns 60 even when it is a leap second.
(<a href="#leap-second-handling">Why?</a>)
Use the proper <a href="#method.format">formatting method</a> to get a human-readable representation.</p>
<pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">leap</span> <span class="op">=</span> <span class="ident">NaiveTime</span>::<span class="ident">from_hms_milli</span>(<span class="number">23</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">1_000</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">leap</span>.<span class="ident">second</span>(), <span class="number">59</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">leap</span>.<span class="ident">format</span>(<span class="string">&quot;%H:%M:%S&quot;</span>).<span class="ident">to_string</span>(), <span class="string">&quot;23:59:60&quot;</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><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#860-862' title='goto source code'>[src]</a></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="#leap-second-handling">leap second</a>.</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">NaiveTime</span>, <span class="ident">Timelike</span>};
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">NaiveTime</span>::<span class="ident">from_hms</span>(<span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>).<span class="ident">nanosecond</span>(), <span class="number">0</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">NaiveTime</span>::<span class="ident">from_hms_nano</span>(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">12_345_678</span>).<span class="ident">nanosecond</span>(), <span class="number">12_345_678</span>);</pre>
<p>Leap seconds may have seemingly out-of-range return values.
You can reduce the range with <code>time.nanosecond() % 1_000_000_000</code>, or
use the proper <a href="#method.format">formatting method</a> to get a human-readable representation.</p>
<pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">leap</span> <span class="op">=</span> <span class="ident">NaiveTime</span>::<span class="ident">from_hms_milli</span>(<span class="number">23</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">1_000</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">leap</span>.<span class="ident">nanosecond</span>(), <span class="number">1_000_000_000</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">leap</span>.<span class="ident">format</span>(<span class="string">&quot;%H:%M:%S%.9f&quot;</span>).<span class="ident">to_string</span>(), <span class="string">&quot;23:59:60.000000000&quot;</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/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a>&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#878-882' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Makes a new <code>NaiveTime</code> with the hour number changed.</p>
<p>Returns <code>None</code> when the resulting <code>NaiveTime</code> would be invalid.</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">NaiveTime</span>, <span class="ident">Timelike</span>};
<span class="kw">let</span> <span class="ident">dt</span> <span class="op">=</span> <span class="ident">NaiveTime</span>::<span class="ident">from_hms_nano</span>(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">12_345_678</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">NaiveTime</span>::<span class="ident">from_hms_nano</span>(<span class="number">7</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">12_345_678</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/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a>&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#898-902' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Makes a new <code>NaiveTime</code> with the minute number changed.</p>
<p>Returns <code>None</code> when the resulting <code>NaiveTime</code> would be invalid.</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">NaiveTime</span>, <span class="ident">Timelike</span>};
<span class="kw">let</span> <span class="ident">dt</span> <span class="op">=</span> <span class="ident">NaiveTime</span>::<span class="ident">from_hms_nano</span>(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">12_345_678</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">NaiveTime</span>::<span class="ident">from_hms_nano</span>(<span class="number">23</span>, <span class="number">45</span>, <span class="number">4</span>, <span class="number">12_345_678</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/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a>&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#920-924' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Makes a new <code>NaiveTime</code> with the second number changed.</p>
<p>Returns <code>None</code> when the resulting <code>NaiveTime</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>
<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">NaiveTime</span>, <span class="ident">Timelike</span>};
<span class="kw">let</span> <span class="ident">dt</span> <span class="op">=</span> <span class="ident">NaiveTime</span>::<span class="ident">from_hms_nano</span>(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">12_345_678</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">NaiveTime</span>::<span class="ident">from_hms_nano</span>(<span class="number">23</span>, <span class="number">56</span>, <span class="number">17</span>, <span class="number">12_345_678</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/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a>&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#955-958' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Makes a new <code>NaiveTime</code> with nanoseconds since the whole non-leap second changed.</p>
<p>Returns <code>None</code> when the resulting <code>NaiveTime</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>
<h1 id="example-23" class="section-header"><a href="#example-23">Example</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">chrono</span>::{<span class="ident">NaiveTime</span>, <span class="ident">Timelike</span>};
<span class="kw">let</span> <span class="ident">dt</span> <span class="op">=</span> <span class="ident">NaiveTime</span>::<span class="ident">from_hms_nano</span>(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">12_345_678</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">NaiveTime</span>::<span class="ident">from_hms_nano</span>(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</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">2_000_000_000</span>), <span class="prelude-val">None</span>);</pre>
<p>Leap seconds can theoretically follow <em>any</em> whole second.
The following would be a proper leap second at the time zone offset of UTC-00:03:57
(there are several historical examples comparable to this &quot;non-sense&quot; offset),
and therefore is allowed.</p>
<pre class="rust rust-example-rendered">
<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="prelude-val">Some</span>(<span class="ident">NaiveTime</span>::<span class="ident">from_hms_nano</span>(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">1_333_333_333</span>)));</pre>
</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><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#975-977' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Returns the number of non-leap seconds past the last midnight.</p>
<h1 id="example-24" class="section-header"><a href="#example-24">Example</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">chrono</span>::{<span class="ident">NaiveTime</span>, <span class="ident">Timelike</span>};
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">NaiveTime</span>::<span class="ident">from_hms</span>(<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>).<span class="ident">num_seconds_from_midnight</span>(),
<span class="number">3723</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">NaiveTime</span>::<span class="ident">from_hms_nano</span>(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">12_345_678</span>).<span class="ident">num_seconds_from_midnight</span>(),
<span class="number">86164</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">NaiveTime</span>::<span class="ident">from_hms_milli</span>(<span class="number">23</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">1_000</span>).<span class="ident">num_seconds_from_midnight</span>(),
<span class="number">86399</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><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/lib.rs.html#920-927' title='goto source code'>[src]</a></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></div><h3 id='impl-Hash' 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/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a></code><a href='#impl-Hash' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#985-990' title='goto source code'>[src]</a></span></h3>
<div class='docblock'><p><code>NaiveTime</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: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>H)</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#986-989' title='goto source code'>[src]</a></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: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>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></span><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.3.0'>1.3.0</div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/hash/mod.rs.html#202-208' title='goto source code'>[src]</a></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 id='impl-Add%3COldDuration%3E' 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/struct.Duration.html" title="struct chrono::Duration">OldDuration</a>&gt; for <a class="struct" href="../../chrono/naive/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a></code><a href='#impl-Add%3COldDuration%3E' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#1050-1057' title='goto source code'>[src]</a></span></h3>
<div class='docblock'><p>An addition of <code>Duration</code> to <code>NaiveTime</code> wraps around and never overflows or underflows.
In particular the addition ignores integral number of days.</p>
<p>As a part of Chrono's <a href="#leap-second-handling">leap second handling</a>,
the addition assumes that <strong>there is no leap second ever</strong>,
except when the <code>NaiveTime</code> itself represents a leap second
in which case the assumption becomes that <strong>there is exactly a single leap second ever</strong>.</p>
<h1 id="example-25" class="section-header"><a href="#example-25">Example</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">chrono</span>::<span class="ident">NaiveTime</span>;
<span class="kw">use</span> <span class="ident">time</span>::<span class="ident">Duration</span>;
<span class="kw">let</span> <span class="ident">from_hmsm</span> <span class="op">=</span> <span class="ident">NaiveTime</span>::<span class="ident">from_hms_milli</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) <span class="op">+</span> <span class="ident">Duration</span>::<span class="ident">zero</span>(), <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) <span class="op">+</span> <span class="ident">Duration</span>::<span class="ident">seconds</span>(<span class="number">1</span>), <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">8</span>, <span class="number">0</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) <span class="op">+</span> <span class="ident">Duration</span>::<span class="ident">seconds</span>(<span class="op">-</span><span class="number">1</span>), <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">0</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) <span class="op">+</span> <span class="ident">Duration</span>::<span class="ident">seconds</span>(<span class="number">60</span> <span class="op">+</span> <span class="number">4</span>), <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">6</span>, <span class="number">11</span>, <span class="number">0</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) <span class="op">+</span> <span class="ident">Duration</span>::<span class="ident">seconds</span>(<span class="number">7</span><span class="kw-2">*</span><span class="number">60</span><span class="kw-2">*</span><span class="number">60</span> <span class="op">-</span> <span class="number">6</span><span class="kw-2">*</span><span class="number">60</span>), <span class="ident">from_hmsm</span>(<span class="number">9</span>, <span class="number">59</span>, <span class="number">7</span>, <span class="number">0</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) <span class="op">+</span> <span class="ident">Duration</span>::<span class="ident">milliseconds</span>(<span class="number">80</span>), <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">80</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">950</span>) <span class="op">+</span> <span class="ident">Duration</span>::<span class="ident">milliseconds</span>(<span class="number">280</span>), <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">8</span>, <span class="number">230</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">950</span>) <span class="op">+</span> <span class="ident">Duration</span>::<span class="ident">milliseconds</span>(<span class="op">-</span><span class="number">980</span>), <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">970</span>));</pre>
<p>The addition wraps around.</p>
<pre class="rust rust-example-rendered">
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) <span class="op">+</span> <span class="ident">Duration</span>::<span class="ident">seconds</span>(<span class="number">22</span><span class="kw-2">*</span><span class="number">60</span><span class="kw-2">*</span><span class="number">60</span>), <span class="ident">from_hmsm</span>(<span class="number">1</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) <span class="op">+</span> <span class="ident">Duration</span>::<span class="ident">seconds</span>(<span class="op">-</span><span class="number">8</span><span class="kw-2">*</span><span class="number">60</span><span class="kw-2">*</span><span class="number">60</span>), <span class="ident">from_hmsm</span>(<span class="number">19</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) <span class="op">+</span> <span class="ident">Duration</span>::<span class="ident">days</span>(<span class="number">800</span>), <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>));</pre>
<p>Leap seconds are handled, but the addition assumes that it is the only leap second happened.</p>
<pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">leap</span> <span class="op">=</span> <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">59</span>, <span class="number">1_300</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">leap</span> <span class="op">+</span> <span class="ident">Duration</span>::<span class="ident">zero</span>(), <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">59</span>, <span class="number">1_300</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">leap</span> <span class="op">+</span> <span class="ident">Duration</span>::<span class="ident">milliseconds</span>(<span class="op">-</span><span class="number">500</span>), <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">59</span>, <span class="number">800</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">leap</span> <span class="op">+</span> <span class="ident">Duration</span>::<span class="ident">milliseconds</span>(<span class="number">500</span>), <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">59</span>, <span class="number">1_800</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">leap</span> <span class="op">+</span> <span class="ident">Duration</span>::<span class="ident">milliseconds</span>(<span class="number">800</span>), <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">6</span>, <span class="number">0</span>, <span class="number">100</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">leap</span> <span class="op">+</span> <span class="ident">Duration</span>::<span class="ident">seconds</span>(<span class="number">10</span>), <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">6</span>, <span class="number">9</span>, <span class="number">300</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">leap</span> <span class="op">+</span> <span class="ident">Duration</span>::<span class="ident">seconds</span>(<span class="op">-</span><span class="number">10</span>), <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">50</span>, <span class="number">300</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">leap</span> <span class="op">+</span> <span class="ident">Duration</span>::<span class="ident">days</span>(<span class="number">1</span>), <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">59</span>, <span class="number">300</span>));</pre>
</div><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.Add.html#associatedtype.Output' class="type">Output</a> = <a class="struct" href="../../chrono/naive/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a></code></span></h4>
<div class='docblock'><p>The resulting type after applying the <code>+</code> operator.</p>
</div><h4 id='method.add-1' class="method"><span id='add.v-1' 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/struct.Duration.html" title="struct chrono::Duration">OldDuration</a>) -&gt; <a class="struct" href="../../chrono/naive/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#1054-1056' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Performs the <code>+</code> operation.</p>
</div></div><h3 id='impl-AddAssign%3COldDuration%3E' class='impl'><span class='in-band'><code>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/arith/trait.AddAssign.html" title="trait core::ops::arith::AddAssign">AddAssign</a>&lt;<a class="struct" href="../../chrono/struct.Duration.html" title="struct chrono::Duration">OldDuration</a>&gt; for <a class="struct" href="../../chrono/naive/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a></code><a href='#impl-AddAssign%3COldDuration%3E' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#1059-1064' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.add_assign' class="method"><span id='add_assign.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/ops/arith/trait.AddAssign.html#tymethod.add_assign' class='fnname'>add_assign</a>(&amp;mut self, rhs: <a class="struct" href="../../chrono/struct.Duration.html" title="struct chrono::Duration">OldDuration</a>)</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#1061-1063' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Performs the <code>+=</code> operation.</p>
</div></div><h3 id='impl-Sub%3COldDuration%3E' 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/struct.Duration.html" title="struct chrono::Duration">OldDuration</a>&gt; for <a class="struct" href="../../chrono/naive/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a></code><a href='#impl-Sub%3COldDuration%3E' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#1120-1127' title='goto source code'>[src]</a></span></h3>
<div class='docblock'><p>A subtraction of <code>Duration</code> from <code>NaiveTime</code> wraps around and never overflows or underflows.
In particular the addition ignores integral number of days.
It is same to the addition with a negated <code>Duration</code>.</p>
<p>As a part of Chrono's <a href="#leap-second-handling">leap second handling</a>,
the addition assumes that <strong>there is no leap second ever</strong>,
except when the <code>NaiveTime</code> itself represents a leap second
in which case the assumption becomes that <strong>there is exactly a single leap second ever</strong>.</p>
<h1 id="example-26" class="section-header"><a href="#example-26">Example</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">chrono</span>::<span class="ident">NaiveTime</span>;
<span class="kw">use</span> <span class="ident">time</span>::<span class="ident">Duration</span>;
<span class="kw">let</span> <span class="ident">from_hmsm</span> <span class="op">=</span> <span class="ident">NaiveTime</span>::<span class="ident">from_hms_milli</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) <span class="op">-</span> <span class="ident">Duration</span>::<span class="ident">zero</span>(), <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) <span class="op">-</span> <span class="ident">Duration</span>::<span class="ident">seconds</span>(<span class="number">1</span>), <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">0</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) <span class="op">-</span> <span class="ident">Duration</span>::<span class="ident">seconds</span>(<span class="number">60</span> <span class="op">+</span> <span class="number">5</span>), <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">4</span>, <span class="number">2</span>, <span class="number">0</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) <span class="op">-</span> <span class="ident">Duration</span>::<span class="ident">seconds</span>(<span class="number">2</span><span class="kw-2">*</span><span class="number">60</span><span class="kw-2">*</span><span class="number">60</span> <span class="op">+</span> <span class="number">6</span><span class="kw-2">*</span><span class="number">60</span>), <span class="ident">from_hmsm</span>(<span class="number">0</span>, <span class="number">59</span>, <span class="number">7</span>, <span class="number">0</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) <span class="op">-</span> <span class="ident">Duration</span>::<span class="ident">milliseconds</span>(<span class="number">80</span>), <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">920</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">950</span>) <span class="op">-</span> <span class="ident">Duration</span>::<span class="ident">milliseconds</span>(<span class="number">280</span>), <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">670</span>));</pre>
<p>The subtraction wraps around.</p>
<pre class="rust rust-example-rendered">
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) <span class="op">-</span> <span class="ident">Duration</span>::<span class="ident">seconds</span>(<span class="number">8</span><span class="kw-2">*</span><span class="number">60</span><span class="kw-2">*</span><span class="number">60</span>), <span class="ident">from_hmsm</span>(<span class="number">19</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) <span class="op">-</span> <span class="ident">Duration</span>::<span class="ident">days</span>(<span class="number">800</span>), <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>));</pre>
<p>Leap seconds are handled, but the subtraction assumes that it is the only leap second happened.</p>
<pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">leap</span> <span class="op">=</span> <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">59</span>, <span class="number">1_300</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">leap</span> <span class="op">-</span> <span class="ident">Duration</span>::<span class="ident">zero</span>(), <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">59</span>, <span class="number">1_300</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">leap</span> <span class="op">-</span> <span class="ident">Duration</span>::<span class="ident">milliseconds</span>(<span class="number">200</span>), <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">59</span>, <span class="number">1_100</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">leap</span> <span class="op">-</span> <span class="ident">Duration</span>::<span class="ident">milliseconds</span>(<span class="number">500</span>), <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">59</span>, <span class="number">800</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">leap</span> <span class="op">-</span> <span class="ident">Duration</span>::<span class="ident">seconds</span>(<span class="number">60</span>), <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">0</span>, <span class="number">300</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">leap</span> <span class="op">-</span> <span class="ident">Duration</span>::<span class="ident">days</span>(<span class="number">1</span>), <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">6</span>, <span class="number">0</span>, <span class="number">300</span>));</pre>
</div><div class='impl-items'><h4 id='associatedtype.Output-3' class="type"><span id='Output.t-3' 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/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</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/struct.Duration.html" title="struct chrono::Duration">OldDuration</a>) -&gt; <a class="struct" href="../../chrono/naive/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#1124-1126' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Performs the <code>-</code> operation.</p>
</div></div><h3 id='impl-SubAssign%3COldDuration%3E' class='impl'><span class='in-band'><code>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/arith/trait.SubAssign.html" title="trait core::ops::arith::SubAssign">SubAssign</a>&lt;<a class="struct" href="../../chrono/struct.Duration.html" title="struct chrono::Duration">OldDuration</a>&gt; for <a class="struct" href="../../chrono/naive/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a></code><a href='#impl-SubAssign%3COldDuration%3E' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#1129-1134' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.sub_assign' class="method"><span id='sub_assign.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/ops/arith/trait.SubAssign.html#tymethod.sub_assign' class='fnname'>sub_assign</a>(&amp;mut self, rhs: <a class="struct" href="../../chrono/struct.Duration.html" title="struct chrono::Duration">OldDuration</a>)</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#1131-1133' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Performs the <code>-=</code> operation.</p>
</div></div><h3 id='impl-Sub%3CNaiveTime%3E' 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/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a>&gt; for <a class="struct" href="../../chrono/naive/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a></code><a href='#impl-Sub%3CNaiveTime%3E' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#1187-1194' title='goto source code'>[src]</a></span></h3>
<div class='docblock'><p>Subtracts another <code>NaiveTime</code> from the current time.
Returns a <code>Duration</code> within +/- 1 day.
This does not overflow or underflow at all.</p>
<p>As a part of Chrono's <a href="#leap-second-handling">leap second handling</a>,
the subtraction assumes that <strong>there is no leap second ever</strong>,
except when any of the <code>NaiveTime</code>s themselves represents a leap second
in which case the assumption becomes that
<strong>there are exactly one (or two) leap second(s) ever</strong>.</p>
<p>The implementation is a wrapper around
<a href="#method.signed_duration_since"><code>NaiveTime::signed_duration_since</code></a>.</p>
<h1 id="example-27" class="section-header"><a href="#example-27">Example</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">chrono</span>::<span class="ident">NaiveTime</span>;
<span class="kw">use</span> <span class="ident">time</span>::<span class="ident">Duration</span>;
<span class="kw">let</span> <span class="ident">from_hmsm</span> <span class="op">=</span> <span class="ident">NaiveTime</span>::<span class="ident">from_hms_milli</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>) <span class="op">-</span> <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>), <span class="ident">Duration</span>::<span class="ident">zero</span>());
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>) <span class="op">-</span> <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">875</span>), <span class="ident">Duration</span>::<span class="ident">milliseconds</span>(<span class="number">25</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>) <span class="op">-</span> <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">925</span>), <span class="ident">Duration</span>::<span class="ident">milliseconds</span>(<span class="number">975</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>) <span class="op">-</span> <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">0</span>, <span class="number">900</span>), <span class="ident">Duration</span>::<span class="ident">seconds</span>(<span class="number">7</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>) <span class="op">-</span> <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">0</span>, <span class="number">7</span>, <span class="number">900</span>), <span class="ident">Duration</span>::<span class="ident">seconds</span>(<span class="number">5</span> <span class="op">*</span> <span class="number">60</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>) <span class="op">-</span> <span class="ident">from_hmsm</span>(<span class="number">0</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>), <span class="ident">Duration</span>::<span class="ident">seconds</span>(<span class="number">3</span> <span class="op">*</span> <span class="number">3600</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>) <span class="op">-</span> <span class="ident">from_hmsm</span>(<span class="number">4</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>), <span class="ident">Duration</span>::<span class="ident">seconds</span>(<span class="op">-</span><span class="number">3600</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>) <span class="op">-</span> <span class="ident">from_hmsm</span>(<span class="number">2</span>, <span class="number">4</span>, <span class="number">6</span>, <span class="number">800</span>),
<span class="ident">Duration</span>::<span class="ident">seconds</span>(<span class="number">3600</span> <span class="op">+</span> <span class="number">60</span> <span class="op">+</span> <span class="number">1</span>) <span class="op">+</span> <span class="ident">Duration</span>::<span class="ident">milliseconds</span>(<span class="number">100</span>));</pre>
<p>Leap seconds are handled, but the subtraction assumes that
there were no other leap seconds happened.</p>
<pre class="rust rust-example-rendered">
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">0</span>, <span class="number">59</span>, <span class="number">1_000</span>) <span class="op">-</span> <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">0</span>, <span class="number">59</span>, <span class="number">0</span>), <span class="ident">Duration</span>::<span class="ident">seconds</span>(<span class="number">1</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">0</span>, <span class="number">59</span>, <span class="number">1_500</span>) <span class="op">-</span> <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">0</span>, <span class="number">59</span>, <span class="number">0</span>),
<span class="ident">Duration</span>::<span class="ident">milliseconds</span>(<span class="number">1500</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">0</span>, <span class="number">59</span>, <span class="number">1_000</span>) <span class="op">-</span> <span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>), <span class="ident">Duration</span>::<span class="ident">seconds</span>(<span class="number">60</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>) <span class="op">-</span> <span class="ident">from_hmsm</span>(<span class="number">2</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">1_000</span>), <span class="ident">Duration</span>::<span class="ident">seconds</span>(<span class="number">1</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">from_hmsm</span>(<span class="number">3</span>, <span class="number">0</span>, <span class="number">59</span>, <span class="number">1_000</span>) <span class="op">-</span> <span class="ident">from_hmsm</span>(<span class="number">2</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">1_000</span>),
<span class="ident">Duration</span>::<span class="ident">seconds</span>(<span class="number">61</span>));</pre>
</div><div class='impl-items'><h4 id='associatedtype.Output-4' class="type"><span id='Output.t-4' 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/struct.Duration.html" title="struct chrono::Duration">OldDuration</a></code></span></h4>
<div class='docblock'><p>The resulting type after applying the <code>-</code> operator.</p>
</div><h4 id='method.sub-2' class="method"><span id='sub.v-2' 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/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a>) -&gt; <a class="struct" href="../../chrono/struct.Duration.html" title="struct chrono::Duration">OldDuration</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#1191-1193' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Performs the <code>-</code> operation.</p>
</div></div><h3 id='impl-Debug' 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/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a></code><a href='#impl-Debug' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#1224-1244' title='goto source code'>[src]</a></span></h3>
<div class='docblock'><p>The <code>Debug</code> output of the naive time <code>t</code> is same to
<a href="../format/strftime/index.html"><code>t.format(&quot;%H:%M:%S%.f&quot;)</code></a>.</p>
<p>The string printed can be readily parsed via the <code>parse</code> method on <code>str</code>.</p>
<p>It should be noted that, for leap seconds not on the minute boundary,
it may print a representation not distinguishable from non-leap seconds.
This doesn't matter in practice, since such leap seconds never happened.
(By the time of the first leap second on 1972-06-30,
every time zone offset around the world has standardized to the 5-minute alignment.)</p>
<h1 id="example-28" class="section-header"><a href="#example-28">Example</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">chrono</span>::<span class="ident">NaiveTime</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;{:?}&quot;</span>, <span class="ident">NaiveTime</span>::<span class="ident">from_hms</span>(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>)), <span class="string">&quot;23:56:04&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;{:?}&quot;</span>, <span class="ident">NaiveTime</span>::<span class="ident">from_hms_milli</span>(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">12</span>)), <span class="string">&quot;23:56:04.012&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;{:?}&quot;</span>, <span class="ident">NaiveTime</span>::<span class="ident">from_hms_micro</span>(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">1234</span>)), <span class="string">&quot;23:56:04.001234&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;{:?}&quot;</span>, <span class="ident">NaiveTime</span>::<span class="ident">from_hms_nano</span>(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">123456</span>)), <span class="string">&quot;23:56:04.000123456&quot;</span>);</pre>
<p>Leap seconds may also be used.</p>
<pre class="rust rust-example-rendered">
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;{:?}&quot;</span>, <span class="ident">NaiveTime</span>::<span class="ident">from_hms_milli</span>(<span class="number">6</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">1_500</span>)), <span class="string">&quot;06:59:60.500&quot;</span>);</pre>
</div><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><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#1225-1243' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
</div></div><h3 id='impl-Display' 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/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a></code><a href='#impl-Display' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#1274-1276' title='goto source code'>[src]</a></span></h3>
<div class='docblock'><p>The <code>Display</code> output of the naive time <code>t</code> is same to
<a href="../format/strftime/index.html"><code>t.format(&quot;%H:%M:%S%.f&quot;)</code></a>.</p>
<p>The string printed can be readily parsed via the <code>parse</code> method on <code>str</code>.</p>
<p>It should be noted that, for leap seconds not on the minute boundary,
it may print a representation not distinguishable from non-leap seconds.
This doesn't matter in practice, since such leap seconds never happened.
(By the time of the first leap second on 1972-06-30,
every time zone offset around the world has standardized to the 5-minute alignment.)</p>
<h1 id="example-29" class="section-header"><a href="#example-29">Example</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">chrono</span>::<span class="ident">NaiveTime</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;{}&quot;</span>, <span class="ident">NaiveTime</span>::<span class="ident">from_hms</span>(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>)), <span class="string">&quot;23:56:04&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;{}&quot;</span>, <span class="ident">NaiveTime</span>::<span class="ident">from_hms_milli</span>(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">12</span>)), <span class="string">&quot;23:56:04.012&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;{}&quot;</span>, <span class="ident">NaiveTime</span>::<span class="ident">from_hms_micro</span>(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">1234</span>)), <span class="string">&quot;23:56:04.001234&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;{}&quot;</span>, <span class="ident">NaiveTime</span>::<span class="ident">from_hms_nano</span>(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">123456</span>)), <span class="string">&quot;23:56:04.000123456&quot;</span>);</pre>
<p>Leap seconds may also be used.</p>
<pre class="rust rust-example-rendered">
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;{}&quot;</span>, <span class="ident">NaiveTime</span>::<span class="ident">from_hms_milli</span>(<span class="number">6</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">1_500</span>)), <span class="string">&quot;06:59:60.500&quot;</span>);</pre>
</div><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><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#1275' title='goto source code'>[src]</a></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 id='impl-FromStr' 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/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a></code><a href='#impl-FromStr' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#1297-1314' title='goto source code'>[src]</a></span></h3>
<div class='docblock'><p>Parsing a <code>str</code> into a <code>NaiveTime</code> uses the same format,
<a href="../format/strftime/index.html"><code>%H:%M:%S%.f</code></a>, as in <code>Debug</code> and <code>Display</code>.</p>
<h1 id="example-30" class="section-header"><a href="#example-30">Example</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">chrono</span>::<span class="ident">NaiveTime</span>;
<span class="kw">let</span> <span class="ident">t</span> <span class="op">=</span> <span class="ident">NaiveTime</span>::<span class="ident">from_hms</span>(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="string">&quot;23:56:04&quot;</span>.<span class="ident">parse</span>::<span class="op">&lt;</span><span class="ident">NaiveTime</span><span class="op">&gt;</span>(), <span class="prelude-val">Ok</span>(<span class="ident">t</span>));
<span class="kw">let</span> <span class="ident">t</span> <span class="op">=</span> <span class="ident">NaiveTime</span>::<span class="ident">from_hms_nano</span>(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">12_345_678</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="string">&quot;23:56:4.012345678&quot;</span>.<span class="ident">parse</span>::<span class="op">&lt;</span><span class="ident">NaiveTime</span><span class="op">&gt;</span>(), <span class="prelude-val">Ok</span>(<span class="ident">t</span>));
<span class="kw">let</span> <span class="ident">t</span> <span class="op">=</span> <span class="ident">NaiveTime</span>::<span class="ident">from_hms_nano</span>(<span class="number">23</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">1_234_567_890</span>); <span class="comment">// leap second</span>
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="string">&quot;23:59:60.23456789&quot;</span>.<span class="ident">parse</span>::<span class="op">&lt;</span><span class="ident">NaiveTime</span><span class="op">&gt;</span>(), <span class="prelude-val">Ok</span>(<span class="ident">t</span>));
<span class="macro">assert</span><span class="macro">!</span>(<span class="string">&quot;foo&quot;</span>.<span class="ident">parse</span>::<span class="op">&lt;</span><span class="ident">NaiveTime</span><span class="op">&gt;</span>().<span class="ident">is_err</span>());</pre>
</div><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/struct.NaiveTime.html" title="struct chrono::naive::NaiveTime">NaiveTime</a>&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/chrono/naive/time.rs.html#1300-1313' title='goto source code'>[src]</a></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><kbd>?</kbd></dt>
<dd>Show this help dialog</dd>
<dt><kbd>S</kbd></dt>
<dd>Focus the search field</dd>
<dt><kbd></kbd></dt>
<dd>Move up in search results</dd>
<dt><kbd></kbd></dt>
<dd>Move down in search results</dd>
<dt><kbd></kbd></dt>
<dd>Switch tab</dd>
<dt><kbd>&#9166;</kbd></dt>
<dd>Go to active search result</dd>
<dt><kbd>+</kbd></dt>
<dd>Expand all sections</dd>
<dt><kbd>-</kbd></dt>
<dd>Collapse 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>