-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathstruct.NaiveTime.html
917 lines (846 loc) · 189 KB
/
struct.NaiveTime.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="ISO 8601 time without timezone. Allows for the nanosecond precision and optional leap second representation."><title>NaiveTime in chrono - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-46132b98.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="chrono" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0 (4d91de4e4 2025-02-17)" data-channel="1.85.0" data-search-js="search-75f5ac3e.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc struct"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../chrono/index.html">chrono</a><span class="version">0.4.40</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Naive<wbr>Time</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#leap-second-handling" title="Leap Second Handling">Leap Second Handling</a><ul><li><a href="#representing-leap-seconds" title="Representing Leap Seconds">Representing Leap Seconds</a></li><li><a href="#date-and-time-arithmetics" title="Date And Time Arithmetics">Date And Time Arithmetics</a></li><li><a href="#reading-and-writing-leap-seconds" title="Reading And Writing Leap Seconds">Reading And Writing Leap Seconds</a></li></ul></li></ul><h3><a href="#fields">Fields</a></h3><ul class="block structfield"><li><a href="#structfield.frac" title="frac">frac</a></li><li><a href="#structfield.secs" title="secs">secs</a></li></ul><h3><a href="#implementations">Associated Constants</a></h3><ul class="block associatedconstant"><li><a href="#associatedconstant.MAX" title="MAX">MAX</a></li><li><a href="#associatedconstant.MIN" title="MIN">MIN</a></li></ul><h3><a href="#implementations">Methods</a></h3><ul class="block method"><li><a href="#method.format" title="format">format</a></li><li><a href="#method.format_with_items" title="format_with_items">format_with_items</a></li><li><a href="#method.from_hms" title="from_hms">from_hms</a></li><li><a href="#method.from_hms_micro" title="from_hms_micro">from_hms_micro</a></li><li><a href="#method.from_hms_micro_opt" title="from_hms_micro_opt">from_hms_micro_opt</a></li><li><a href="#method.from_hms_milli" title="from_hms_milli">from_hms_milli</a></li><li><a href="#method.from_hms_milli_opt" title="from_hms_milli_opt">from_hms_milli_opt</a></li><li><a href="#method.from_hms_nano" title="from_hms_nano">from_hms_nano</a></li><li><a href="#method.from_hms_nano_opt" title="from_hms_nano_opt">from_hms_nano_opt</a></li><li><a href="#method.from_hms_opt" title="from_hms_opt">from_hms_opt</a></li><li><a href="#method.from_num_seconds_from_midnight" title="from_num_seconds_from_midnight">from_num_seconds_from_midnight</a></li><li><a href="#method.from_num_seconds_from_midnight_opt" title="from_num_seconds_from_midnight_opt">from_num_seconds_from_midnight_opt</a></li><li><a href="#method.hms" title="hms">hms</a></li><li><a href="#method.nanosecond" title="nanosecond">nanosecond</a></li><li><a href="#method.num_seconds_from_midnight" title="num_seconds_from_midnight">num_seconds_from_midnight</a></li><li><a href="#method.overflowing_add_offset" title="overflowing_add_offset">overflowing_add_offset</a></li><li><a href="#method.overflowing_add_signed" title="overflowing_add_signed">overflowing_add_signed</a></li><li><a href="#method.overflowing_sub_offset" title="overflowing_sub_offset">overflowing_sub_offset</a></li><li><a href="#method.overflowing_sub_signed" title="overflowing_sub_signed">overflowing_sub_signed</a></li><li><a href="#method.parse_and_remainder" title="parse_and_remainder">parse_and_remainder</a></li><li><a href="#method.parse_from_str" title="parse_from_str">parse_from_str</a></li><li><a href="#method.signed_duration_since" title="signed_duration_since">signed_duration_since</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block trait-implementation"><li><a href="#impl-Add%3CDuration%3E-for-NaiveTime" title="Add<Duration>">Add<Duration></a></li><li><a href="#impl-Add%3CFixedOffset%3E-for-NaiveTime" title="Add<FixedOffset>">Add<FixedOffset></a></li><li><a href="#impl-Add%3CTimeDelta%3E-for-NaiveTime" title="Add<TimeDelta>">Add<TimeDelta></a></li><li><a href="#impl-AddAssign%3CDuration%3E-for-NaiveTime" title="AddAssign<Duration>">AddAssign<Duration></a></li><li><a href="#impl-AddAssign%3CTimeDelta%3E-for-NaiveTime" title="AddAssign<TimeDelta>">AddAssign<TimeDelta></a></li><li><a href="#impl-Clone-for-NaiveTime" title="Clone">Clone</a></li><li><a href="#impl-Copy-for-NaiveTime" title="Copy">Copy</a></li><li><a href="#impl-Debug-for-NaiveTime" title="Debug">Debug</a></li><li><a href="#impl-Default-for-NaiveTime" title="Default">Default</a></li><li><a href="#impl-Deserialize%3C'de%3E-for-NaiveTime" title="Deserialize<'de>">Deserialize<'de></a></li><li><a href="#impl-Display-for-NaiveTime" title="Display">Display</a></li><li><a href="#impl-Eq-for-NaiveTime" title="Eq">Eq</a></li><li><a href="#impl-FromStr-for-NaiveTime" title="FromStr">FromStr</a></li><li><a href="#impl-Hash-for-NaiveTime" title="Hash">Hash</a></li><li><a href="#impl-Ord-for-NaiveTime" title="Ord">Ord</a></li><li><a href="#impl-PartialEq-for-NaiveTime" title="PartialEq">PartialEq</a></li><li><a href="#impl-PartialOrd-for-NaiveTime" title="PartialOrd">PartialOrd</a></li><li><a href="#impl-Serialize-for-NaiveTime" title="Serialize">Serialize</a></li><li><a href="#impl-StructuralPartialEq-for-NaiveTime" title="StructuralPartialEq">StructuralPartialEq</a></li><li><a href="#impl-Sub-for-NaiveTime" title="Sub">Sub</a></li><li><a href="#impl-Sub%3CDuration%3E-for-NaiveTime" title="Sub<Duration>">Sub<Duration></a></li><li><a href="#impl-Sub%3CFixedOffset%3E-for-NaiveTime" title="Sub<FixedOffset>">Sub<FixedOffset></a></li><li><a href="#impl-Sub%3CTimeDelta%3E-for-NaiveTime" title="Sub<TimeDelta>">Sub<TimeDelta></a></li><li><a href="#impl-SubAssign%3CDuration%3E-for-NaiveTime" title="SubAssign<Duration>">SubAssign<Duration></a></li><li><a href="#impl-SubAssign%3CTimeDelta%3E-for-NaiveTime" title="SubAssign<TimeDelta>">SubAssign<TimeDelta></a></li><li><a href="#impl-Timelike-for-NaiveTime" title="Timelike">Timelike</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block synthetic-implementation"><li><a href="#impl-Freeze-for-NaiveTime" title="Freeze">Freeze</a></li><li><a href="#impl-RefUnwindSafe-for-NaiveTime" title="RefUnwindSafe">RefUnwindSafe</a></li><li><a href="#impl-Send-for-NaiveTime" title="Send">Send</a></li><li><a href="#impl-Sync-for-NaiveTime" title="Sync">Sync</a></li><li><a href="#impl-Unpin-for-NaiveTime" title="Unpin">Unpin</a></li><li><a href="#impl-UnwindSafe-for-NaiveTime" title="UnwindSafe">UnwindSafe</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block blanket-implementation"><li><a href="#impl-Any-for-T" title="Any">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-T" title="Borrow<T>">Borrow<T></a></li><li><a href="#impl-BorrowMut%3CT%3E-for-T" title="BorrowMut<T>">BorrowMut<T></a></li><li><a href="#impl-CloneToUninit-for-T" title="CloneToUninit">CloneToUninit</a></li><li><a href="#impl-DeserializeOwned-for-T" title="DeserializeOwned">DeserializeOwned</a></li><li><a href="#impl-From%3CT%3E-for-T" title="From<T>">From<T></a></li><li><a href="#impl-Into%3CU%3E-for-T" title="Into<U>">Into<U></a></li><li><a href="#impl-SubsecRound-for-T" title="SubsecRound">SubsecRound</a></li><li><a href="#impl-ToOwned-for-T" title="ToOwned">ToOwned</a></li><li><a href="#impl-ToString-for-T" title="ToString">ToString</a></li><li><a href="#impl-TryFrom%3CU%3E-for-T" title="TryFrom<U>">TryFrom<U></a></li><li><a href="#impl-TryInto%3CU%3E-for-T" title="TryInto<U>">TryInto<U></a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate chrono</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="index.html">chrono</a></span><h1>Struct <span class="struct">NaiveTime</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/chrono/naive/time/mod.rs.html#220-223">Source</a> </span></div><pre class="rust item-decl"><code>pub struct NaiveTime {
secs: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>,
frac: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>,
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>ISO 8601 time without timezone.
Allows for the nanosecond precision and optional leap second representation.</p>
<h2 id="leap-second-handling"><a class="doc-anchor" href="#leap-second-handling">§</a>Leap Second Handling</h2>
<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>
<h3 id="representing-leap-seconds"><a class="doc-anchor" href="#representing-leap-seconds">§</a>Representing Leap Seconds</h3>
<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>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{NaiveDate, NaiveTime};
<span class="kw">let </span>t = NaiveTime::from_hms_milli_opt(<span class="number">8</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">1_000</span>).unwrap();
<span class="kw">let </span>dt1 = NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">7</span>, <span class="number">1</span>)
.unwrap()
.and_hms_micro_opt(<span class="number">8</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">1_000_000</span>)
.unwrap();
<span class="kw">let </span>dt2 = NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">6</span>, <span class="number">30</span>)
.unwrap()
.and_hms_nano_opt(<span class="number">23</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">1_000_000_000</span>)
.unwrap()
.and_utc();</code></pre></div>
<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>
<h3 id="date-and-time-arithmetics"><a class="doc-anchor" href="#date-and-time-arithmetics">§</a>Date And Time Arithmetics</h3>
<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 + TimeDelta</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:01:59</code>.</li>
<li><code>03:00:59 + 61s = 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 - TimeDelta</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 + TimeDelta</code> unconditionally equals to <code>TimeDelta + Time</code>.</p>
</li>
<li>
<p><code>Time - TimeDelta</code> unconditionally equals to <code>Time + (-TimeDelta)</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 + TimeDelta1) - TimeDelta2</code> no longer equals to <code>Time + (TimeDelta1 - TimeDelta2)</code>
for two positive durations.</p>
<ul>
<li>
<p>As a special case, <code>(Time + TimeDelta) - TimeDelta</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 + TimeDelta1) + TimeDelta2</code> equals to <code>Time + (TimeDelta1 + TimeDelta2)</code>
for two positive durations.</p>
</li>
</ul>
</li>
</ul>
<h3 id="reading-and-writing-leap-seconds"><a class="doc-anchor" href="#reading-and-writing-leap-seconds">§</a>Reading And Writing Leap Seconds</h3>
<p>The “typical” 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>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::NaiveDate;
<span class="kw">let </span>dt = NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">6</span>, <span class="number">30</span>)
.unwrap()
.and_hms_milli_opt(<span class="number">23</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">1_000</span>)
.unwrap()
.and_utc();
<span class="macro">assert_eq!</span>(<span class="macro">format!</span>(<span class="string">"{:?}"</span>, dt), <span class="string">"2015-06-30T23:59:60Z"</span>);</code></pre></div>
<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 “exotic” 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>
<p>A <code>NaiveTime</code> with a leap second that is not on a minute boundary can only be created from a
<a href="struct.DateTime.html" title="struct chrono::DateTime"><code>DateTime</code></a> with fractional minutes as offset, or using
<a href="trait.Timelike.html#tymethod.with_nanosecond" title="method chrono::Timelike::with_nanosecond"><code>Timelike::with_nanosecond()</code></a>.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{FixedOffset, NaiveDate, TimeZone};
<span class="kw">let </span>paramaribo_pre1945 = FixedOffset::east_opt(-<span class="number">13236</span>).unwrap(); <span class="comment">// -03:40:36
</span><span class="kw">let </span>leap_sec_2015 =
NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">6</span>, <span class="number">30</span>).unwrap().and_hms_milli_opt(<span class="number">23</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">1_000</span>).unwrap();
<span class="kw">let </span>dt1 = paramaribo_pre1945.from_utc_datetime(<span class="kw-2">&</span>leap_sec_2015);
<span class="macro">assert_eq!</span>(<span class="macro">format!</span>(<span class="string">"{:?}"</span>, dt1), <span class="string">"2015-06-30T20:19:24-03:40:36"</span>);
<span class="macro">assert_eq!</span>(<span class="macro">format!</span>(<span class="string">"{:?}"</span>, dt1.time()), <span class="string">"20:19:24"</span>);
<span class="kw">let </span>next_sec = NaiveDate::from_ymd_opt(<span class="number">2015</span>, <span class="number">7</span>, <span class="number">1</span>).unwrap().and_hms_opt(<span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>).unwrap();
<span class="kw">let </span>dt2 = paramaribo_pre1945.from_utc_datetime(<span class="kw-2">&</span>next_sec);
<span class="macro">assert_eq!</span>(<span class="macro">format!</span>(<span class="string">"{:?}"</span>, dt2), <span class="string">"2015-06-30T20:19:24-03:40:36"</span>);
<span class="macro">assert_eq!</span>(<span class="macro">format!</span>(<span class="string">"{:?}"</span>, dt2.time()), <span class="string">"20:19:24"</span>);
<span class="macro">assert!</span>(dt1.time() != dt2.time());
<span class="macro">assert!</span>(dt1.time().to_string() == dt2.time().to_string());</code></pre></div>
<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></details><h2 id="fields" class="fields section-header">Fields<a href="#fields" class="anchor">§</a></h2><span id="structfield.secs" class="structfield section-header"><a href="#structfield.secs" class="anchor field">§</a><code>secs: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a></code></span><span id="structfield.frac" class="structfield section-header"><a href="#structfield.frac" class="anchor field">§</a><code>frac: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a></code></span><h2 id="implementations" class="section-header">Implementations<a href="#implementations" class="anchor">§</a></h2><div id="implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-NaiveTime" class="impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#241-900">Source</a><a href="#impl-NaiveTime" class="anchor">§</a><h3 class="code-header">impl <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedconstant.MIN" class="associatedconstant"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#898">Source</a><h4 class="code-header">pub const <a href="#associatedconstant.MIN" class="constant">MIN</a>: Self</h4></section></summary><div class="docblock"><p>The earliest possible <code>NaiveTime</code></p>
</div></details><section id="associatedconstant.MAX" class="associatedconstant"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#899">Source</a><h4 class="code-header">pub(super) const <a href="#associatedconstant.MAX" class="constant">MAX</a>: Self</h4></section><details class="toggle method-toggle" open><summary><section id="method.from_hms" class="method"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#253-255">Source</a><h4 class="code-header">pub const fn <a href="#method.from_hms" class="fn">from_hms</a>(hour: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>, min: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>, sec: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>) -> <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h4></section><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated since 0.4.23: use <code>from_hms_opt()</code> instead</span></div></span></summary><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>
<h5 id="panics"><a class="doc-anchor" href="#panics">§</a>Panics</h5>
<p>Panics on invalid hour, minute and/or second.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.from_hms_opt" class="method"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#281-283">Source</a><h4 class="code-header">pub const fn <a href="#method.from_hms_opt" class="fn">from_hms_opt</a>(hour: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>, min: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>, sec: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.85.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a>></h4></section></summary><div class="docblock"><p>Makes a new <code>NaiveTime</code> from hour, minute and second.</p>
<p>The millisecond part is allowed to exceed 1,000,000,000 in order to represent a
<a href="#leap-second-handling">leap second</a>, but only when <code>sec == 59</code>.</p>
<h5 id="errors"><a class="doc-anchor" href="#errors">§</a>Errors</h5>
<p>Returns <code>None</code> on invalid hour, minute and/or second.</p>
<h5 id="example"><a class="doc-anchor" href="#example">§</a>Example</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::NaiveTime;
<span class="kw">let </span>from_hms_opt = NaiveTime::from_hms_opt;
<span class="macro">assert!</span>(from_hms_opt(<span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>).is_some());
<span class="macro">assert!</span>(from_hms_opt(<span class="number">23</span>, <span class="number">59</span>, <span class="number">59</span>).is_some());
<span class="macro">assert!</span>(from_hms_opt(<span class="number">24</span>, <span class="number">0</span>, <span class="number">0</span>).is_none());
<span class="macro">assert!</span>(from_hms_opt(<span class="number">23</span>, <span class="number">60</span>, <span class="number">0</span>).is_none());
<span class="macro">assert!</span>(from_hms_opt(<span class="number">23</span>, <span class="number">59</span>, <span class="number">60</span>).is_none());</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.from_hms_milli" class="method"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#296-298">Source</a><h4 class="code-header">pub const fn <a href="#method.from_hms_milli" class="fn">from_hms_milli</a>(
hour: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>,
min: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>,
sec: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>,
milli: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>,
) -> <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h4></section><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated since 0.4.23: use <code>from_hms_milli_opt()</code> instead</span></div></span></summary><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>
<h5 id="panics-1"><a class="doc-anchor" href="#panics-1">§</a>Panics</h5>
<p>Panics on invalid hour, minute, second and/or millisecond.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.from_hms_milli_opt" class="method"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#326-334">Source</a><h4 class="code-header">pub const fn <a href="#method.from_hms_milli_opt" class="fn">from_hms_milli_opt</a>(
hour: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>,
min: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>,
sec: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>,
milli: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>,
) -> <a class="enum" href="https://doc.rust-lang.org/1.85.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a>></h4></section></summary><div class="docblock"><p>Makes a new <code>NaiveTime</code> from hour, minute, second and millisecond.</p>
<p>The millisecond part is allowed to exceed 1,000,000,000 in order to represent a
<a href="#leap-second-handling">leap second</a>, but only when <code>sec == 59</code>.</p>
<h5 id="errors-1"><a class="doc-anchor" href="#errors-1">§</a>Errors</h5>
<p>Returns <code>None</code> on invalid hour, minute, second and/or millisecond.</p>
<h5 id="example-1"><a class="doc-anchor" href="#example-1">§</a>Example</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::NaiveTime;
<span class="kw">let </span>from_hmsm_opt = NaiveTime::from_hms_milli_opt;
<span class="macro">assert!</span>(from_hmsm_opt(<span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>).is_some());
<span class="macro">assert!</span>(from_hmsm_opt(<span class="number">23</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">999</span>).is_some());
<span class="macro">assert!</span>(from_hmsm_opt(<span class="number">23</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">1_999</span>).is_some()); <span class="comment">// a leap second after 23:59:59
</span><span class="macro">assert!</span>(from_hmsm_opt(<span class="number">24</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>).is_none());
<span class="macro">assert!</span>(from_hmsm_opt(<span class="number">23</span>, <span class="number">60</span>, <span class="number">0</span>, <span class="number">0</span>).is_none());
<span class="macro">assert!</span>(from_hmsm_opt(<span class="number">23</span>, <span class="number">59</span>, <span class="number">60</span>, <span class="number">0</span>).is_none());
<span class="macro">assert!</span>(from_hmsm_opt(<span class="number">23</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">2_000</span>).is_none());</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.from_hms_micro" class="method"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#347-349">Source</a><h4 class="code-header">pub const fn <a href="#method.from_hms_micro" class="fn">from_hms_micro</a>(
hour: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>,
min: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>,
sec: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>,
micro: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>,
) -> <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h4></section><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated since 0.4.23: use <code>from_hms_micro_opt()</code> instead</span></div></span></summary><div class="docblock"><p>Makes a new <code>NaiveTime</code> from hour, minute, second and microsecond.</p>
<p>The microsecond part is allowed to exceed 1,000,000,000 in order to represent a
<a href="#leap-second-handling">leap second</a>, but only when <code>sec == 59</code>.</p>
<h5 id="panics-2"><a class="doc-anchor" href="#panics-2">§</a>Panics</h5>
<p>Panics on invalid hour, minute, second and/or microsecond.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.from_hms_micro_opt" class="method"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#377-385">Source</a><h4 class="code-header">pub const fn <a href="#method.from_hms_micro_opt" class="fn">from_hms_micro_opt</a>(
hour: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>,
min: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>,
sec: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>,
micro: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>,
) -> <a class="enum" href="https://doc.rust-lang.org/1.85.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a>></h4></section></summary><div class="docblock"><p>Makes a new <code>NaiveTime</code> from hour, minute, second and microsecond.</p>
<p>The microsecond part is allowed to exceed 1,000,000,000 in order to represent a
<a href="#leap-second-handling">leap second</a>, but only when <code>sec == 59</code>.</p>
<h5 id="errors-2"><a class="doc-anchor" href="#errors-2">§</a>Errors</h5>
<p>Returns <code>None</code> on invalid hour, minute, second and/or microsecond.</p>
<h5 id="example-2"><a class="doc-anchor" href="#example-2">§</a>Example</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::NaiveTime;
<span class="kw">let </span>from_hmsu_opt = NaiveTime::from_hms_micro_opt;
<span class="macro">assert!</span>(from_hmsu_opt(<span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>).is_some());
<span class="macro">assert!</span>(from_hmsu_opt(<span class="number">23</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">999_999</span>).is_some());
<span class="macro">assert!</span>(from_hmsu_opt(<span class="number">23</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">1_999_999</span>).is_some()); <span class="comment">// a leap second after 23:59:59
</span><span class="macro">assert!</span>(from_hmsu_opt(<span class="number">24</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>).is_none());
<span class="macro">assert!</span>(from_hmsu_opt(<span class="number">23</span>, <span class="number">60</span>, <span class="number">0</span>, <span class="number">0</span>).is_none());
<span class="macro">assert!</span>(from_hmsu_opt(<span class="number">23</span>, <span class="number">59</span>, <span class="number">60</span>, <span class="number">0</span>).is_none());
<span class="macro">assert!</span>(from_hmsu_opt(<span class="number">23</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">2_000_000</span>).is_none());</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.from_hms_nano" class="method"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#398-400">Source</a><h4 class="code-header">pub const fn <a href="#method.from_hms_nano" class="fn">from_hms_nano</a>(
hour: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>,
min: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>,
sec: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>,
nano: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>,
) -> <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h4></section><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated since 0.4.23: use <code>from_hms_nano_opt()</code> instead</span></div></span></summary><div class="docblock"><p>Makes a new <code>NaiveTime</code> from hour, minute, second and nanosecond.</p>
<p>The nanosecond part is allowed to exceed 1,000,000,000 in order to represent a
<a href="#leap-second-handling">leap second</a>, but only when <code>sec == 59</code>.</p>
<h5 id="panics-3"><a class="doc-anchor" href="#panics-3">§</a>Panics</h5>
<p>Panics on invalid hour, minute, second and/or nanosecond.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.from_hms_nano_opt" class="method"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#428-437">Source</a><h4 class="code-header">pub const fn <a href="#method.from_hms_nano_opt" class="fn">from_hms_nano_opt</a>(
hour: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>,
min: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>,
sec: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>,
nano: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>,
) -> <a class="enum" href="https://doc.rust-lang.org/1.85.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a>></h4></section></summary><div class="docblock"><p>Makes a new <code>NaiveTime</code> from hour, minute, second and nanosecond.</p>
<p>The nanosecond part is allowed to exceed 1,000,000,000 in order to represent a
<a href="#leap-second-handling">leap second</a>, but only when <code>sec == 59</code>.</p>
<h5 id="errors-3"><a class="doc-anchor" href="#errors-3">§</a>Errors</h5>
<p>Returns <code>None</code> on invalid hour, minute, second and/or nanosecond.</p>
<h5 id="example-3"><a class="doc-anchor" href="#example-3">§</a>Example</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::NaiveTime;
<span class="kw">let </span>from_hmsn_opt = NaiveTime::from_hms_nano_opt;
<span class="macro">assert!</span>(from_hmsn_opt(<span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>).is_some());
<span class="macro">assert!</span>(from_hmsn_opt(<span class="number">23</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">999_999_999</span>).is_some());
<span class="macro">assert!</span>(from_hmsn_opt(<span class="number">23</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">1_999_999_999</span>).is_some()); <span class="comment">// a leap second after 23:59:59
</span><span class="macro">assert!</span>(from_hmsn_opt(<span class="number">24</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>).is_none());
<span class="macro">assert!</span>(from_hmsn_opt(<span class="number">23</span>, <span class="number">60</span>, <span class="number">0</span>, <span class="number">0</span>).is_none());
<span class="macro">assert!</span>(from_hmsn_opt(<span class="number">23</span>, <span class="number">59</span>, <span class="number">60</span>, <span class="number">0</span>).is_none());
<span class="macro">assert!</span>(from_hmsn_opt(<span class="number">23</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">2_000_000_000</span>).is_none());</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.from_num_seconds_from_midnight" class="method"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#450-452">Source</a><h4 class="code-header">pub const fn <a href="#method.from_num_seconds_from_midnight" class="fn">from_num_seconds_from_midnight</a>(secs: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>, nano: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>) -> <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h4></section><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated since 0.4.23: use <code>from_num_seconds_from_midnight_opt()</code> instead</span></div></span></summary><div class="docblock"><p>Makes a new <code>NaiveTime</code> from the number of seconds since midnight and nanosecond.</p>
<p>The nanosecond part is allowed to exceed 1,000,000,000 in order to represent a
<a href="#leap-second-handling">leap second</a>, but only when <code>secs % 60 == 59</code>.</p>
<h5 id="panics-4"><a class="doc-anchor" href="#panics-4">§</a>Panics</h5>
<p>Panics on invalid number of seconds and/or nanosecond.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.from_num_seconds_from_midnight_opt" class="method"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#478-483">Source</a><h4 class="code-header">pub const fn <a href="#method.from_num_seconds_from_midnight_opt" class="fn">from_num_seconds_from_midnight_opt</a>(
secs: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>,
nano: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>,
) -> <a class="enum" href="https://doc.rust-lang.org/1.85.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a>></h4></section></summary><div class="docblock"><p>Makes a new <code>NaiveTime</code> from the number of seconds since midnight and nanosecond.</p>
<p>The nanosecond part is allowed to exceed 1,000,000,000 in order to represent a
<a href="#leap-second-handling">leap second</a>, but only when <code>secs % 60 == 59</code>.</p>
<h5 id="errors-4"><a class="doc-anchor" href="#errors-4">§</a>Errors</h5>
<p>Returns <code>None</code> on invalid number of seconds and/or nanosecond.</p>
<h5 id="example-4"><a class="doc-anchor" href="#example-4">§</a>Example</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::NaiveTime;
<span class="kw">let </span>from_nsecs_opt = NaiveTime::from_num_seconds_from_midnight_opt;
<span class="macro">assert!</span>(from_nsecs_opt(<span class="number">0</span>, <span class="number">0</span>).is_some());
<span class="macro">assert!</span>(from_nsecs_opt(<span class="number">86399</span>, <span class="number">999_999_999</span>).is_some());
<span class="macro">assert!</span>(from_nsecs_opt(<span class="number">86399</span>, <span class="number">1_999_999_999</span>).is_some()); <span class="comment">// a leap second after 23:59:59
</span><span class="macro">assert!</span>(from_nsecs_opt(<span class="number">86_400</span>, <span class="number">0</span>).is_none());
<span class="macro">assert!</span>(from_nsecs_opt(<span class="number">86399</span>, <span class="number">2_000_000_000</span>).is_none());</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.parse_from_str" class="method"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#553-557">Source</a><h4 class="code-header">pub fn <a href="#method.parse_from_str" class="fn">parse_from_str</a>(s: &<a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.str.html">str</a>, fmt: &<a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.str.html">str</a>) -> <a class="type" href="format/type.ParseResult.html" title="type chrono::format::ParseResult">ParseResult</a><<a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a>></h4></section></summary><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" title="mod chrono::format::strftime"><code>format::strftime</code> module</a>
on the supported escape sequences.</p>
<h5 id="example-5"><a class="doc-anchor" href="#example-5">§</a>Example</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::NaiveTime;
<span class="kw">let </span>parse_from_str = NaiveTime::parse_from_str;
<span class="macro">assert_eq!</span>(
parse_from_str(<span class="string">"23:56:04"</span>, <span class="string">"%H:%M:%S"</span>),
<span class="prelude-val">Ok</span>(NaiveTime::from_hms_opt(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>).unwrap())
);
<span class="macro">assert_eq!</span>(
parse_from_str(<span class="string">"pm012345.6789"</span>, <span class="string">"%p%I%M%S%.f"</span>),
<span class="prelude-val">Ok</span>(NaiveTime::from_hms_micro_opt(<span class="number">13</span>, <span class="number">23</span>, <span class="number">45</span>, <span class="number">678_900</span>).unwrap())
);</code></pre></div>
<p>Date and offset is ignored for the purpose of parsing.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(
parse_from_str(<span class="string">"2014-5-17T12:34:56+09:30"</span>, <span class="string">"%Y-%m-%dT%H:%M:%S%z"</span>),
<span class="prelude-val">Ok</span>(NaiveTime::from_hms_opt(<span class="number">12</span>, <span class="number">34</span>, <span class="number">56</span>).unwrap())
);</code></pre></div>
<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>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(
parse_from_str(<span class="string">"08:59:60.123"</span>, <span class="string">"%H:%M:%S%.f"</span>),
<span class="prelude-val">Ok</span>(NaiveTime::from_hms_milli_opt(<span class="number">8</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">1_123</span>).unwrap())
);</code></pre></div>
<p>Missing seconds are assumed to be zero,
but out-of-bound times or insufficient fields are errors otherwise.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(parse_from_str(<span class="string">"7:15"</span>, <span class="string">"%H:%M"</span>), <span class="prelude-val">Ok</span>(NaiveTime::from_hms_opt(<span class="number">7</span>, <span class="number">15</span>, <span class="number">0</span>).unwrap()));
<span class="macro">assert!</span>(parse_from_str(<span class="string">"04m33s"</span>, <span class="string">"%Mm%Ss"</span>).is_err());
<span class="macro">assert!</span>(parse_from_str(<span class="string">"12"</span>, <span class="string">"%H"</span>).is_err());
<span class="macro">assert!</span>(parse_from_str(<span class="string">"17:60"</span>, <span class="string">"%H:%M"</span>).is_err());
<span class="macro">assert!</span>(parse_from_str(<span class="string">"24:00:00"</span>, <span class="string">"%H:%M:%S"</span>).is_err());</code></pre></div>
<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>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert!</span>(parse_from_str(<span class="string">"13:07 AM"</span>, <span class="string">"%H:%M %p"</span>).is_err());</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.parse_and_remainder" class="method"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#575-579">Source</a><h4 class="code-header">pub fn <a href="#method.parse_and_remainder" class="fn">parse_and_remainder</a><'a>(
s: &'a <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.str.html">str</a>,
fmt: &<a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.str.html">str</a>,
) -> <a class="type" href="format/type.ParseResult.html" title="type chrono::format::ParseResult">ParseResult</a><(<a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a>, &'a <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.str.html">str</a>)></h4></section></summary><div class="docblock"><p>Parses a string from a user-specified format into a new <code>NaiveTime</code> value, and a slice with
the remaining portion of the string.
See the <a href="format/strftime/index.html" title="mod chrono::format::strftime"><code>format::strftime</code> module</a>
on the supported escape sequences.</p>
<p>Similar to <a href="#method.parse_from_str"><code>parse_from_str</code></a>.</p>
<h5 id="example-6"><a class="doc-anchor" href="#example-6">§</a>Example</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>(time, remainder) =
NaiveTime::parse_and_remainder(<span class="string">"3h4m33s trailing text"</span>, <span class="string">"%-Hh%-Mm%-Ss"</span>).unwrap();
<span class="macro">assert_eq!</span>(time, NaiveTime::from_hms_opt(<span class="number">3</span>, <span class="number">4</span>, <span class="number">33</span>).unwrap());
<span class="macro">assert_eq!</span>(remainder, <span class="string">" trailing text"</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.overflowing_add_signed" class="method"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#605-641">Source</a><h4 class="code-header">pub const fn <a href="#method.overflowing_add_signed" class="fn">overflowing_add_signed</a>(&self, rhs: <a class="struct" href="struct.TimeDelta.html" title="struct chrono::TimeDelta">TimeDelta</a>) -> (<a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a>, <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.i64.html">i64</a>)</h4></section></summary><div class="docblock"><p>Adds given <code>TimeDelta</code> to the current time, and also returns the number of <em>seconds</em>
in the integral number of days ignored from the addition.</p>
<h5 id="example-7"><a class="doc-anchor" href="#example-7">§</a>Example</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{NaiveTime, TimeDelta};
<span class="kw">let </span>from_hms = |h, m, s| NaiveTime::from_hms_opt(h, m, s).unwrap();
<span class="macro">assert_eq!</span>(
from_hms(<span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>).overflowing_add_signed(TimeDelta::try_hours(<span class="number">11</span>).unwrap()),
(from_hms(<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>(
from_hms(<span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>).overflowing_add_signed(TimeDelta::try_hours(<span class="number">23</span>).unwrap()),
(from_hms(<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>(
from_hms(<span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>).overflowing_add_signed(TimeDelta::try_hours(-<span class="number">7</span>).unwrap()),
(from_hms(<span class="number">20</span>, <span class="number">4</span>, <span class="number">5</span>), -<span class="number">86_400</span>)
);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.overflowing_sub_signed" class="method"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#668-671">Source</a><h4 class="code-header">pub const fn <a href="#method.overflowing_sub_signed" class="fn">overflowing_sub_signed</a>(&self, rhs: <a class="struct" href="struct.TimeDelta.html" title="struct chrono::TimeDelta">TimeDelta</a>) -> (<a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a>, <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.i64.html">i64</a>)</h4></section></summary><div class="docblock"><p>Subtracts given <code>TimeDelta</code> from the current time, and also returns the number of <em>seconds</em>
in the integral number of days ignored from the subtraction.</p>
<h5 id="example-8"><a class="doc-anchor" href="#example-8">§</a>Example</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{NaiveTime, TimeDelta};
<span class="kw">let </span>from_hms = |h, m, s| NaiveTime::from_hms_opt(h, m, s).unwrap();
<span class="macro">assert_eq!</span>(
from_hms(<span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>).overflowing_sub_signed(TimeDelta::try_hours(<span class="number">2</span>).unwrap()),
(from_hms(<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>(
from_hms(<span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>).overflowing_sub_signed(TimeDelta::try_hours(<span class="number">17</span>).unwrap()),
(from_hms(<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>(
from_hms(<span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>).overflowing_sub_signed(TimeDelta::try_hours(-<span class="number">22</span>).unwrap()),
(from_hms(<span class="number">1</span>, <span class="number">4</span>, <span class="number">5</span>), -<span class="number">86_400</span>)
);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.signed_duration_since" class="method"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#741-766">Source</a><h4 class="code-header">pub const fn <a href="#method.signed_duration_since" class="fn">signed_duration_since</a>(self, rhs: <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a>) -> <a class="struct" href="struct.TimeDelta.html" title="struct chrono::TimeDelta">TimeDelta</a></h4></section></summary><div class="docblock"><p>Subtracts another <code>NaiveTime</code> from the current time.
Returns a <code>TimeDelta</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>
<h5 id="example-9"><a class="doc-anchor" href="#example-9">§</a>Example</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{NaiveTime, TimeDelta};
<span class="kw">let </span>from_hmsm = |h, m, s, milli| NaiveTime::from_hms_milli_opt(h, m, s, milli).unwrap();
<span class="kw">let </span>since = NaiveTime::signed_duration_since;
<span class="macro">assert_eq!</span>(since(from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>), from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>)), TimeDelta::zero());
<span class="macro">assert_eq!</span>(
since(from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>), from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">875</span>)),
TimeDelta::try_milliseconds(<span class="number">25</span>).unwrap()
);
<span class="macro">assert_eq!</span>(
since(from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>), from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">925</span>)),
TimeDelta::try_milliseconds(<span class="number">975</span>).unwrap()
);
<span class="macro">assert_eq!</span>(
since(from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>), from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">0</span>, <span class="number">900</span>)),
TimeDelta::try_seconds(<span class="number">7</span>).unwrap()
);
<span class="macro">assert_eq!</span>(
since(from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>), from_hmsm(<span class="number">3</span>, <span class="number">0</span>, <span class="number">7</span>, <span class="number">900</span>)),
TimeDelta::try_seconds(<span class="number">5 </span>* <span class="number">60</span>).unwrap()
);
<span class="macro">assert_eq!</span>(
since(from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>), from_hmsm(<span class="number">0</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>)),
TimeDelta::try_seconds(<span class="number">3 </span>* <span class="number">3600</span>).unwrap()
);
<span class="macro">assert_eq!</span>(
since(from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>), from_hmsm(<span class="number">4</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>)),
TimeDelta::try_seconds(-<span class="number">3600</span>).unwrap()
);
<span class="macro">assert_eq!</span>(
since(from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>), from_hmsm(<span class="number">2</span>, <span class="number">4</span>, <span class="number">6</span>, <span class="number">800</span>)),
TimeDelta::try_seconds(<span class="number">3600 </span>+ <span class="number">60 </span>+ <span class="number">1</span>).unwrap() + TimeDelta::try_milliseconds(<span class="number">100</span>).unwrap()
);</code></pre></div>
<p>Leap seconds are handled, but the subtraction assumes that
there were no other leap seconds happened.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(since(from_hmsm(<span class="number">3</span>, <span class="number">0</span>, <span class="number">59</span>, <span class="number">1_000</span>), from_hmsm(<span class="number">3</span>, <span class="number">0</span>, <span class="number">59</span>, <span class="number">0</span>)),
TimeDelta::try_seconds(<span class="number">1</span>).unwrap());
<span class="macro">assert_eq!</span>(since(from_hmsm(<span class="number">3</span>, <span class="number">0</span>, <span class="number">59</span>, <span class="number">1_500</span>), from_hmsm(<span class="number">3</span>, <span class="number">0</span>, <span class="number">59</span>, <span class="number">0</span>)),
TimeDelta::try_milliseconds(<span class="number">1500</span>).unwrap());
<span class="macro">assert_eq!</span>(since(from_hmsm(<span class="number">3</span>, <span class="number">0</span>, <span class="number">59</span>, <span class="number">1_000</span>), from_hmsm(<span class="number">3</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>)),
TimeDelta::try_seconds(<span class="number">60</span>).unwrap());
<span class="macro">assert_eq!</span>(since(from_hmsm(<span class="number">3</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>), from_hmsm(<span class="number">2</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">1_000</span>)),
TimeDelta::try_seconds(<span class="number">1</span>).unwrap());
<span class="macro">assert_eq!</span>(since(from_hmsm(<span class="number">3</span>, <span class="number">0</span>, <span class="number">59</span>, <span class="number">1_000</span>), from_hmsm(<span class="number">2</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">1_000</span>)),
TimeDelta::try_seconds(<span class="number">61</span>).unwrap());</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.overflowing_add_offset" class="method"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#774-779">Source</a><h4 class="code-header">pub(super) const fn <a href="#method.overflowing_add_offset" class="fn">overflowing_add_offset</a>(
&self,
offset: <a class="struct" href="struct.FixedOffset.html" title="struct chrono::FixedOffset">FixedOffset</a>,
) -> (<a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a>, <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.i32.html">i32</a>)</h4></section></summary><div class="docblock"><p>Adds given <code>FixedOffset</code> to the current time, and returns the number of days that should be
added to a date as a result of the offset (either <code>-1</code>, <code>0</code>, or <code>1</code> because the offset is
always less than 24h).</p>
<p>This method is similar to <a href="#method.overflowing_add_signed"><code>overflowing_add_signed</code></a>, but
preserves leap seconds.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.overflowing_sub_offset" class="method"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#787-792">Source</a><h4 class="code-header">pub(super) const fn <a href="#method.overflowing_sub_offset" class="fn">overflowing_sub_offset</a>(
&self,
offset: <a class="struct" href="struct.FixedOffset.html" title="struct chrono::FixedOffset">FixedOffset</a>,
) -> (<a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a>, <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.i32.html">i32</a>)</h4></section></summary><div class="docblock"><p>Subtracts given <code>FixedOffset</code> from the current time, and returns the number of days that
should be added to a date as a result of the offset (either <code>-1</code>, <code>0</code>, or <code>1</code> because the
offset is always less than 24h).</p>
<p>This method is similar to <a href="#method.overflowing_sub_signed"><code>overflowing_sub_signed</code></a>, but
preserves leap seconds.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.format_with_items" class="method"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#824-830">Source</a><h4 class="code-header">pub fn <a href="#method.format_with_items" class="fn">format_with_items</a><'a, I, B>(&self, items: I) -> <a class="struct" href="format/struct.DelayedFormat.html" title="struct chrono::format::DelayedFormat">DelayedFormat</a><I><div class="where">where
I: <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/iter/traits/iterator/trait.Iterator.html" title="trait core::iter::traits::iterator::Iterator">Iterator</a><Item = B> + <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,
B: <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><<a class="enum" href="format/enum.Item.html" title="enum chrono::format::Item">Item</a><'a>>,</div></h4></section></summary><div class="docblock"><p>Formats the time with the specified formatting items.
Otherwise it is the same as 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>
<h5 id="example-10"><a class="doc-anchor" href="#example-10">§</a>Example</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::format::strftime::StrftimeItems;
<span class="kw">use </span>chrono::NaiveTime;
<span class="kw">let </span>fmt = StrftimeItems::new(<span class="string">"%H:%M:%S"</span>);
<span class="kw">let </span>t = NaiveTime::from_hms_opt(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>).unwrap();
<span class="macro">assert_eq!</span>(t.format_with_items(fmt.clone()).to_string(), <span class="string">"23:56:04"</span>);
<span class="macro">assert_eq!</span>(t.format(<span class="string">"%H:%M:%S"</span>).to_string(), <span class="string">"23:56:04"</span>);</code></pre></div>
<p>The resulting <code>DelayedFormat</code> can be formatted directly via the <code>Display</code> trait.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(<span class="macro">format!</span>(<span class="string">"{}"</span>, t.format_with_items(fmt)), <span class="string">"23:56:04"</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.format" class="method"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#869-871">Source</a><h4 class="code-header">pub fn <a href="#method.format" class="fn">format</a><'a>(&self, fmt: &'a <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.str.html">str</a>) -> <a class="struct" href="format/struct.DelayedFormat.html" title="struct chrono::format::DelayedFormat">DelayedFormat</a><<a class="struct" href="format/strftime/struct.StrftimeItems.html" title="struct chrono::format::strftime::StrftimeItems">StrftimeItems</a><'a>></h4></section></summary><div class="docblock"><p>Formats the time with the specified format string.
See the <a href="format/strftime/index.html" title="mod chrono::format::strftime"><code>format::strftime</code> module</a>
on the supported escape sequences.</p>
<p>This returns a <code>DelayedFormat</code>,
which gets converted to a string only when actual formatting happens.
You may use the <code>to_string</code> method to get a <code>String</code>,
or just feed it into <code>print!</code> and other formatting macros.
(In this way it avoids the redundant memory allocation.)</p>
<p>A wrong format string does <em>not</em> issue an error immediately.
Rather, converting or formatting the <code>DelayedFormat</code> fails.
You are recommended to immediately use <code>DelayedFormat</code> for this reason.</p>
<h5 id="example-11"><a class="doc-anchor" href="#example-11">§</a>Example</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::NaiveTime;
<span class="kw">let </span>t = NaiveTime::from_hms_nano_opt(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">12_345_678</span>).unwrap();
<span class="macro">assert_eq!</span>(t.format(<span class="string">"%H:%M:%S"</span>).to_string(), <span class="string">"23:56:04"</span>);
<span class="macro">assert_eq!</span>(t.format(<span class="string">"%H:%M:%S%.6f"</span>).to_string(), <span class="string">"23:56:04.012345"</span>);
<span class="macro">assert_eq!</span>(t.format(<span class="string">"%-I:%M %p"</span>).to_string(), <span class="string">"11:56 PM"</span>);</code></pre></div>
<p>The resulting <code>DelayedFormat</code> can be formatted directly via the <code>Display</code> trait.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(<span class="macro">format!</span>(<span class="string">"{}"</span>, t.format(<span class="string">"%H:%M:%S"</span>)), <span class="string">"23:56:04"</span>);
<span class="macro">assert_eq!</span>(<span class="macro">format!</span>(<span class="string">"{}"</span>, t.format(<span class="string">"%H:%M:%S%.6f"</span>)), <span class="string">"23:56:04.012345"</span>);
<span class="macro">assert_eq!</span>(<span class="macro">format!</span>(<span class="string">"{}"</span>, t.format(<span class="string">"%-I:%M %p"</span>)), <span class="string">"11:56 PM"</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.hms" class="method"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#874-880">Source</a><h4 class="code-header">pub(crate) fn <a href="#method.hms" class="fn">hms</a>(&self) -> (<a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>, <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>, <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>)</h4></section></summary><div class="docblock"><p>Returns a triple of the hour, minute and second numbers.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.num_seconds_from_midnight" class="method"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#886-888">Source</a><h4 class="code-header">pub(crate) const fn <a href="#method.num_seconds_from_midnight" class="fn">num_seconds_from_midnight</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a></h4></section></summary><div class="docblock"><p>Returns the number of non-leap seconds past the last midnight.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.nanosecond" class="method"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#893-895">Source</a><h4 class="code-header">pub(crate) const fn <a href="#method.nanosecond" class="fn">nanosecond</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a></h4></section></summary><div class="docblock"><p>Returns the number of nanoseconds since the whole non-leap second.</p>
</div></details></div></details></div><h2 id="trait-implementations" class="section-header">Trait Implementations<a href="#trait-implementations" class="anchor">§</a></h2><div id="trait-implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-Add%3CDuration%3E-for-NaiveTime" class="impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1230-1242">Source</a><a href="#impl-Add%3CDuration%3E-for-NaiveTime" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/ops/arith/trait.Add.html" title="trait core::ops::arith::Add">Add</a><<a class="struct" href="https://doc.rust-lang.org/1.85.0/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>> for <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h3><div class="docblock"><p>Add <code>std::time::Duration</code> to <code>NaiveTime</code>.</p>
</div></section></summary><div class="docblock"><p>This wraps around and never overflows or underflows.
In particular the addition ignores integral number of days.</p>
</div><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Output-1" class="associatedtype trait-impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1231">Source</a><a href="#associatedtype.Output-1" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.85.0/core/ops/arith/trait.Add.html#associatedtype.Output" class="associatedtype">Output</a> = <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h4></section></summary><div class='docblock'>The resulting type after applying the <code>+</code> operator.</div></details><details class="toggle method-toggle" open><summary><section id="method.add-1" class="method trait-impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1234-1241">Source</a><a href="#method.add-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.0/core/ops/arith/trait.Add.html#tymethod.add" class="fn">add</a>(self, rhs: <a class="struct" href="https://doc.rust-lang.org/1.85.0/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>) -> <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h4></section></summary><div class='docblock'>Performs the <code>+</code> operation. <a href="https://doc.rust-lang.org/1.85.0/core/ops/arith/trait.Add.html#tymethod.add">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Add%3CFixedOffset%3E-for-NaiveTime" class="impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1259-1266">Source</a><a href="#impl-Add%3CFixedOffset%3E-for-NaiveTime" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/ops/arith/trait.Add.html" title="trait core::ops::arith::Add">Add</a><<a class="struct" href="struct.FixedOffset.html" title="struct chrono::FixedOffset">FixedOffset</a>> for <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h3><div class="docblock"><p>Add <code>FixedOffset</code> to <code>NaiveTime</code>.</p>
</div></section></summary><div class="docblock"><p>This wraps around and never overflows or underflows.
In particular the addition ignores integral number of days.</p>
</div><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Output-2" class="associatedtype trait-impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1260">Source</a><a href="#associatedtype.Output-2" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.85.0/core/ops/arith/trait.Add.html#associatedtype.Output" class="associatedtype">Output</a> = <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h4></section></summary><div class='docblock'>The resulting type after applying the <code>+</code> operator.</div></details><details class="toggle method-toggle" open><summary><section id="method.add-2" class="method trait-impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1263-1265">Source</a><a href="#method.add-2" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.0/core/ops/arith/trait.Add.html#tymethod.add" class="fn">add</a>(self, rhs: <a class="struct" href="struct.FixedOffset.html" title="struct chrono::FixedOffset">FixedOffset</a>) -> <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h4></section></summary><div class='docblock'>Performs the <code>+</code> operation. <a href="https://doc.rust-lang.org/1.85.0/core/ops/arith/trait.Add.html#tymethod.add">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Add%3CTimeDelta%3E-for-NaiveTime" class="impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1206-1213">Source</a><a href="#impl-Add%3CTimeDelta%3E-for-NaiveTime" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/ops/arith/trait.Add.html" title="trait core::ops::arith::Add">Add</a><<a class="struct" href="struct.TimeDelta.html" title="struct chrono::TimeDelta">TimeDelta</a>> for <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h3><div class="docblock"><p>Add <code>TimeDelta</code> to <code>NaiveTime</code>.</p>
</div></section></summary><div class="docblock"><p>This 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="struct.NaiveTime.html#leap-second-handling" title="struct chrono::NaiveTime">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>
<h4 id="example-21"><a class="doc-anchor" href="#example-21">§</a>Example</h4>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{NaiveTime, TimeDelta};
<span class="kw">let </span>from_hmsm = |h, m, s, milli| NaiveTime::from_hms_milli_opt(h, m, s, milli).unwrap();
<span class="macro">assert_eq!</span>(from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) + TimeDelta::zero(), from_hmsm(<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>(from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) + TimeDelta::try_seconds(<span class="number">1</span>).unwrap(), from_hmsm(<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>(from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) + TimeDelta::try_seconds(-<span class="number">1</span>).unwrap(), from_hmsm(<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>(
from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) + TimeDelta::try_seconds(<span class="number">60 </span>+ <span class="number">4</span>).unwrap(),
from_hmsm(<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>(
from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) + TimeDelta::try_seconds(<span class="number">7 </span>* <span class="number">60 </span>* <span class="number">60 </span>- <span class="number">6 </span>* <span class="number">60</span>).unwrap(),
from_hmsm(<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>(
from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) + TimeDelta::try_milliseconds(<span class="number">80</span>).unwrap(),
from_hmsm(<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>(
from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">950</span>) + TimeDelta::try_milliseconds(<span class="number">280</span>).unwrap(),
from_hmsm(<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>(
from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">950</span>) + TimeDelta::try_milliseconds(-<span class="number">980</span>).unwrap(),
from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">970</span>)
);</code></pre></div>
<p>The addition wraps around.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) + TimeDelta::try_seconds(<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>).unwrap(), from_hmsm(<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>(from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) + TimeDelta::try_seconds(-<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>).unwrap(), from_hmsm(<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>(from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) + TimeDelta::try_days(<span class="number">800</span>).unwrap(), from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>));</code></pre></div>
<p>Leap seconds are handled, but the addition assumes that it is the only leap second happened.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>leap = from_hmsm(<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>(leap + TimeDelta::zero(), from_hmsm(<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>(leap + TimeDelta::try_milliseconds(-<span class="number">500</span>).unwrap(), from_hmsm(<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>(leap + TimeDelta::try_milliseconds(<span class="number">500</span>).unwrap(), from_hmsm(<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>(leap + TimeDelta::try_milliseconds(<span class="number">800</span>).unwrap(), from_hmsm(<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>(leap + TimeDelta::try_seconds(<span class="number">10</span>).unwrap(), from_hmsm(<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>(leap + TimeDelta::try_seconds(-<span class="number">10</span>).unwrap(), from_hmsm(<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>(leap + TimeDelta::try_days(<span class="number">1</span>).unwrap(), from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">59</span>, <span class="number">300</span>));</code></pre></div>
</div><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Output" class="associatedtype trait-impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1207">Source</a><a href="#associatedtype.Output" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.85.0/core/ops/arith/trait.Add.html#associatedtype.Output" class="associatedtype">Output</a> = <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h4></section></summary><div class='docblock'>The resulting type after applying the <code>+</code> operator.</div></details><details class="toggle method-toggle" open><summary><section id="method.add" class="method trait-impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1210-1212">Source</a><a href="#method.add" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.0/core/ops/arith/trait.Add.html#tymethod.add" class="fn">add</a>(self, rhs: <a class="struct" href="struct.TimeDelta.html" title="struct chrono::TimeDelta">TimeDelta</a>) -> <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h4></section></summary><div class='docblock'>Performs the <code>+</code> operation. <a href="https://doc.rust-lang.org/1.85.0/core/ops/arith/trait.Add.html#tymethod.add">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-AddAssign%3CDuration%3E-for-NaiveTime" class="impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1248-1253">Source</a><a href="#impl-AddAssign%3CDuration%3E-for-NaiveTime" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/ops/arith/trait.AddAssign.html" title="trait core::ops::arith::AddAssign">AddAssign</a><<a class="struct" href="https://doc.rust-lang.org/1.85.0/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>> for <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h3><div class="docblock"><p>Add-assign <code>std::time::Duration</code> to <code>NaiveTime</code>.</p>
</div></section></summary><div class="docblock"><p>This wraps around and never overflows or underflows.
In particular the addition ignores integral number of days.</p>
</div><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.add_assign-1" class="method trait-impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1250-1252">Source</a><a href="#method.add_assign-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.0/core/ops/arith/trait.AddAssign.html#tymethod.add_assign" class="fn">add_assign</a>(&mut self, rhs: <a class="struct" href="https://doc.rust-lang.org/1.85.0/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>)</h4></section></summary><div class='docblock'>Performs the <code>+=</code> operation. <a href="https://doc.rust-lang.org/1.85.0/core/ops/arith/trait.AddAssign.html#tymethod.add_assign">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-AddAssign%3CTimeDelta%3E-for-NaiveTime" class="impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1219-1224">Source</a><a href="#impl-AddAssign%3CTimeDelta%3E-for-NaiveTime" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/ops/arith/trait.AddAssign.html" title="trait core::ops::arith::AddAssign">AddAssign</a><<a class="struct" href="struct.TimeDelta.html" title="struct chrono::TimeDelta">TimeDelta</a>> for <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h3><div class="docblock"><p>Add-assign <code>TimeDelta</code> to <code>NaiveTime</code>.</p>
</div></section></summary><div class="docblock"><p>This wraps around and never overflows or underflows.
In particular the addition ignores integral number of days.</p>
</div><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.add_assign" class="method trait-impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1221-1223">Source</a><a href="#method.add_assign" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.0/core/ops/arith/trait.AddAssign.html#tymethod.add_assign" class="fn">add_assign</a>(&mut self, rhs: <a class="struct" href="struct.TimeDelta.html" title="struct chrono::TimeDelta">TimeDelta</a>)</h4></section></summary><div class='docblock'>Performs the <code>+=</code> operation. <a href="https://doc.rust-lang.org/1.85.0/core/ops/arith/trait.AddAssign.html#tymethod.add_assign">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Clone-for-NaiveTime" class="impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#212">Source</a><a href="#impl-Clone-for-NaiveTime" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> for <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.clone" class="method trait-impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#212">Source</a><a href="#method.clone" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.0/core/clone/trait.Clone.html#tymethod.clone" class="fn">clone</a>(&self) -> <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h4></section></summary><div class='docblock'>Returns a copy of the value. <a href="https://doc.rust-lang.org/1.85.0/core/clone/trait.Clone.html#tymethod.clone">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.clone_from" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.85.0/src/core/clone.rs.html#174">Source</a></span><a href="#method.clone_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.0/core/clone/trait.Clone.html#method.clone_from" class="fn">clone_from</a>(&mut self, source: &Self)</h4></section></summary><div class='docblock'>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/1.85.0/core/clone/trait.Clone.html#method.clone_from">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Debug-for-NaiveTime" class="impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1504-1530">Source</a><a href="#impl-Debug-for-NaiveTime" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h3><div class="docblock"><p>The <code>Debug</code> output of the naive time <code>t</code> is the same as
<a href="format/strftime/index.html" title="mod chrono::format::strftime"><code>t.format("%H:%M:%S%.f")</code></a>.</p>
</div></section></summary><div class="docblock"><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>
<h4 id="example-24"><a class="doc-anchor" href="#example-24">§</a>Example</h4>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::NaiveTime;
<span class="macro">assert_eq!</span>(<span class="macro">format!</span>(<span class="string">"{:?}"</span>, NaiveTime::from_hms_opt(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>).unwrap()), <span class="string">"23:56:04"</span>);
<span class="macro">assert_eq!</span>(
<span class="macro">format!</span>(<span class="string">"{:?}"</span>, NaiveTime::from_hms_milli_opt(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">12</span>).unwrap()),
<span class="string">"23:56:04.012"
</span>);
<span class="macro">assert_eq!</span>(
<span class="macro">format!</span>(<span class="string">"{:?}"</span>, NaiveTime::from_hms_micro_opt(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">1234</span>).unwrap()),
<span class="string">"23:56:04.001234"
</span>);
<span class="macro">assert_eq!</span>(
<span class="macro">format!</span>(<span class="string">"{:?}"</span>, NaiveTime::from_hms_nano_opt(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">123456</span>).unwrap()),
<span class="string">"23:56:04.000123456"
</span>);</code></pre></div>
<p>Leap seconds may also be used.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(
<span class="macro">format!</span>(<span class="string">"{:?}"</span>, NaiveTime::from_hms_milli_opt(<span class="number">6</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">1_500</span>).unwrap()),
<span class="string">"06:59:60.500"
</span>);</code></pre></div>
</div><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.fmt" class="method trait-impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1505-1529">Source</a><a href="#method.fmt" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.0/core/fmt/trait.Debug.html#tymethod.fmt" class="fn">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/1.85.0/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/1.85.0/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></summary><div class='docblock'>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/1.85.0/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Default-for-NaiveTime" class="impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1639-1643">Source</a><a href="#impl-Default-for-NaiveTime" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/default/trait.Default.html" title="trait core::default::Default">Default</a> for <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h3><div class="docblock"><p>The default value for a NaiveTime is midnight, 00:00:00 exactly.</p>
</div></section></summary><div class="docblock"><h4 id="example-27"><a class="doc-anchor" href="#example-27">§</a>Example</h4>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::NaiveTime;
<span class="kw">let </span>default_time = NaiveTime::default();
<span class="macro">assert_eq!</span>(default_time, NaiveTime::from_hms_opt(<span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>).unwrap());</code></pre></div>
</div><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.default" class="method trait-impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1640-1642">Source</a><a href="#method.default" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.0/core/default/trait.Default.html#tymethod.default" class="fn">default</a>() -> Self</h4></section></summary><div class='docblock'>Returns the “default value” for a type. <a href="https://doc.rust-lang.org/1.85.0/core/default/trait.Default.html#tymethod.default">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Deserialize%3C'de%3E-for-NaiveTime" class="impl"><a class="src rightside" href="../src/chrono/naive/time/serde.rs.html#34-41">Source</a><a href="#impl-Deserialize%3C'de%3E-for-NaiveTime" class="anchor">§</a><h3 class="code-header">impl<'de> <a class="trait" href="../serde/de/trait.Deserialize.html" title="trait serde::de::Deserialize">Deserialize</a><'de> for <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.deserialize" class="method trait-impl"><a class="src rightside" href="../src/chrono/naive/time/serde.rs.html#35-40">Source</a><a href="#method.deserialize" class="anchor">§</a><h4 class="code-header">fn <a href="../serde/de/trait.Deserialize.html#tymethod.deserialize" class="fn">deserialize</a><D>(deserializer: D) -> <a class="enum" href="https://doc.rust-lang.org/1.85.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self, D::<a class="associatedtype" href="../serde/de/trait.Deserializer.html#associatedtype.Error" title="type serde::de::Deserializer::Error">Error</a>><div class="where">where
D: <a class="trait" href="../serde/de/trait.Deserializer.html" title="trait serde::de::Deserializer">Deserializer</a><'de>,</div></h4></section></summary><div class='docblock'>Deserialize this value from the given Serde deserializer. <a href="../serde/de/trait.Deserialize.html#tymethod.deserialize">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Display-for-NaiveTime" class="impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1572-1576">Source</a><a href="#impl-Display-for-NaiveTime" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a> for <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h3><div class="docblock"><p>The <code>Display</code> output of the naive time <code>t</code> is the same as
<a href="format/strftime/index.html" title="mod chrono::format::strftime"><code>t.format("%H:%M:%S%.f")</code></a>.</p>
</div></section></summary><div class="docblock"><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>
<h4 id="example-25"><a class="doc-anchor" href="#example-25">§</a>Example</h4>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::NaiveTime;
<span class="macro">assert_eq!</span>(<span class="macro">format!</span>(<span class="string">"{}"</span>, NaiveTime::from_hms_opt(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>).unwrap()), <span class="string">"23:56:04"</span>);
<span class="macro">assert_eq!</span>(
<span class="macro">format!</span>(<span class="string">"{}"</span>, NaiveTime::from_hms_milli_opt(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">12</span>).unwrap()),
<span class="string">"23:56:04.012"
</span>);
<span class="macro">assert_eq!</span>(
<span class="macro">format!</span>(<span class="string">"{}"</span>, NaiveTime::from_hms_micro_opt(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">1234</span>).unwrap()),
<span class="string">"23:56:04.001234"
</span>);
<span class="macro">assert_eq!</span>(
<span class="macro">format!</span>(<span class="string">"{}"</span>, NaiveTime::from_hms_nano_opt(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">123456</span>).unwrap()),
<span class="string">"23:56:04.000123456"
</span>);</code></pre></div>
<p>Leap seconds may also be used.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(
<span class="macro">format!</span>(<span class="string">"{}"</span>, NaiveTime::from_hms_milli_opt(<span class="number">6</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">1_500</span>).unwrap()),
<span class="string">"06:59:60.500"
</span>);</code></pre></div>
</div><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.fmt-1" class="method trait-impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1573-1575">Source</a><a href="#method.fmt-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.0/core/fmt/trait.Display.html#tymethod.fmt" class="fn">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/1.85.0/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/1.85.0/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></summary><div class='docblock'>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/1.85.0/core/fmt/trait.Display.html#tymethod.fmt">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-FromStr-for-NaiveTime" class="impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1601-1627">Source</a><a href="#impl-FromStr-for-NaiveTime" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/str/traits/trait.FromStr.html" title="trait core::str::traits::FromStr">FromStr</a> for <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></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" title="mod chrono::format::strftime"><code>%H:%M:%S%.f</code></a>, as in <code>Debug</code> and <code>Display</code>.</p>
</div></section></summary><div class="docblock"><h4 id="example-26"><a class="doc-anchor" href="#example-26">§</a>Example</h4>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::NaiveTime;
<span class="kw">let </span>t = NaiveTime::from_hms_opt(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>).unwrap();
<span class="macro">assert_eq!</span>(<span class="string">"23:56:04"</span>.parse::<NaiveTime>(), <span class="prelude-val">Ok</span>(t));
<span class="kw">let </span>t = NaiveTime::from_hms_nano_opt(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">12_345_678</span>).unwrap();
<span class="macro">assert_eq!</span>(<span class="string">"23:56:4.012345678"</span>.parse::<NaiveTime>(), <span class="prelude-val">Ok</span>(t));
<span class="kw">let </span>t = NaiveTime::from_hms_nano_opt(<span class="number">23</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">1_234_567_890</span>).unwrap(); <span class="comment">// leap second
</span><span class="macro">assert_eq!</span>(<span class="string">"23:59:60.23456789"</span>.parse::<NaiveTime>(), <span class="prelude-val">Ok</span>(t));
<span class="comment">// Seconds are optional
</span><span class="kw">let </span>t = NaiveTime::from_hms_opt(<span class="number">23</span>, <span class="number">56</span>, <span class="number">0</span>).unwrap();
<span class="macro">assert_eq!</span>(<span class="string">"23:56"</span>.parse::<NaiveTime>(), <span class="prelude-val">Ok</span>(t));
<span class="macro">assert!</span>(<span class="string">"foo"</span>.parse::<NaiveTime>().is_err());</code></pre></div>
</div><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Err" class="associatedtype trait-impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1602">Source</a><a href="#associatedtype.Err" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.85.0/core/str/traits/trait.FromStr.html#associatedtype.Err" class="associatedtype">Err</a> = <a class="struct" href="format/struct.ParseError.html" title="struct chrono::format::ParseError">ParseError</a></h4></section></summary><div class='docblock'>The associated error which can be returned from parsing.</div></details><details class="toggle method-toggle" open><summary><section id="method.from_str" class="method trait-impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1604-1626">Source</a><a href="#method.from_str" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.0/core/str/traits/trait.FromStr.html#tymethod.from_str" class="fn">from_str</a>(s: &<a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.str.html">str</a>) -> <a class="type" href="format/type.ParseResult.html" title="type chrono::format::ParseResult">ParseResult</a><<a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a>></h4></section></summary><div class='docblock'>Parses a string <code>s</code> to return a value of this type. <a href="https://doc.rust-lang.org/1.85.0/core/str/traits/trait.FromStr.html#tymethod.from_str">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Hash-for-NaiveTime" class="impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#212">Source</a><a href="#impl-Hash-for-NaiveTime" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a> for <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.hash" class="method trait-impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#212">Source</a><a href="#method.hash" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.0/core/hash/trait.Hash.html#tymethod.hash" class="fn">hash</a><__H: <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/hash/trait.Hasher.html" title="trait core::hash::Hasher">Hasher</a>>(&self, state: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.reference.html">&mut __H</a>)</h4></section></summary><div class='docblock'>Feeds this value into the given <a href="https://doc.rust-lang.org/1.85.0/core/hash/trait.Hasher.html" title="trait core::hash::Hasher"><code>Hasher</code></a>. <a href="https://doc.rust-lang.org/1.85.0/core/hash/trait.Hash.html#tymethod.hash">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.hash_slice" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.3.0">1.3.0</span> · <a class="src" href="https://doc.rust-lang.org/1.85.0/src/core/hash/mod.rs.html#235-237">Source</a></span><a href="#method.hash_slice" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.0/core/hash/trait.Hash.html#method.hash_slice" class="fn">hash_slice</a><H>(data: &[Self], state: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.reference.html">&mut H</a>)<div class="where">where
H: <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/hash/trait.Hasher.html" title="trait core::hash::Hasher">Hasher</a>,
Self: <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class='docblock'>Feeds a slice of this type into the given <a href="https://doc.rust-lang.org/1.85.0/core/hash/trait.Hasher.html" title="trait core::hash::Hasher"><code>Hasher</code></a>. <a href="https://doc.rust-lang.org/1.85.0/core/hash/trait.Hash.html#method.hash_slice">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Ord-for-NaiveTime" class="impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#212">Source</a><a href="#impl-Ord-for-NaiveTime" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/cmp/trait.Ord.html" title="trait core::cmp::Ord">Ord</a> for <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.cmp" class="method trait-impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#212">Source</a><a href="#method.cmp" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.0/core/cmp/trait.Ord.html#tymethod.cmp" class="fn">cmp</a>(&self, other: &<a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.85.0/core/cmp/enum.Ordering.html" title="enum core::cmp::Ordering">Ordering</a></h4></section></summary><div class='docblock'>This method returns an <a href="https://doc.rust-lang.org/1.85.0/core/cmp/enum.Ordering.html" title="enum core::cmp::Ordering"><code>Ordering</code></a> between <code>self</code> and <code>other</code>. <a href="https://doc.rust-lang.org/1.85.0/core/cmp/trait.Ord.html#tymethod.cmp">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.max" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.21.0">1.21.0</span> · <a class="src" href="https://doc.rust-lang.org/1.85.0/src/core/cmp.rs.html#980-982">Source</a></span><a href="#method.max" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.0/core/cmp/trait.Ord.html#method.max" class="fn">max</a>(self, other: Self) -> Self<div class="where">where
Self: <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class='docblock'>Compares and returns the maximum of two values. <a href="https://doc.rust-lang.org/1.85.0/core/cmp/trait.Ord.html#method.max">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.min" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.21.0">1.21.0</span> · <a class="src" href="https://doc.rust-lang.org/1.85.0/src/core/cmp.rs.html#1001-1003">Source</a></span><a href="#method.min" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.0/core/cmp/trait.Ord.html#method.min" class="fn">min</a>(self, other: Self) -> Self<div class="where">where
Self: <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class='docblock'>Compares and returns the minimum of two values. <a href="https://doc.rust-lang.org/1.85.0/core/cmp/trait.Ord.html#method.min">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.clamp" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.50.0">1.50.0</span> · <a class="src" href="https://doc.rust-lang.org/1.85.0/src/core/cmp.rs.html#1027-1029">Source</a></span><a href="#method.clamp" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.0/core/cmp/trait.Ord.html#method.clamp" class="fn">clamp</a>(self, min: Self, max: Self) -> Self<div class="where">where
Self: <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class='docblock'>Restrict a value to a certain interval. <a href="https://doc.rust-lang.org/1.85.0/core/cmp/trait.Ord.html#method.clamp">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-PartialEq-for-NaiveTime" class="impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#212">Source</a><a href="#impl-PartialEq-for-NaiveTime" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a> for <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.eq" class="method trait-impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#212">Source</a><a href="#method.eq" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.0/core/cmp/trait.PartialEq.html#tymethod.eq" class="fn">eq</a>(&self, other: &<a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'>Tests for <code>self</code> and <code>other</code> values to be equal, and is used by <code>==</code>.</div></details><details class="toggle method-toggle" open><summary><section id="method.ne" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.85.0/src/core/cmp.rs.html#261">Source</a></span><a href="#method.ne" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.0/core/cmp/trait.PartialEq.html#method.ne" class="fn">ne</a>(&self, other: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.reference.html">&Rhs</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'>Tests for <code>!=</code>. The default implementation is almost always sufficient,
and should not be overridden without very good reason.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-PartialOrd-for-NaiveTime" class="impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#212">Source</a><a href="#impl-PartialOrd-for-NaiveTime" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a> for <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.partial_cmp" class="method trait-impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#212">Source</a><a href="#method.partial_cmp" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.0/core/cmp/trait.PartialOrd.html#tymethod.partial_cmp" class="fn">partial_cmp</a>(&self, other: &<a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.85.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="enum" href="https://doc.rust-lang.org/1.85.0/core/cmp/enum.Ordering.html" title="enum core::cmp::Ordering">Ordering</a>></h4></section></summary><div class='docblock'>This method returns an ordering between <code>self</code> and <code>other</code> values if one exists. <a href="https://doc.rust-lang.org/1.85.0/core/cmp/trait.PartialOrd.html#tymethod.partial_cmp">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.lt" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.85.0/src/core/cmp.rs.html#1335">Source</a></span><a href="#method.lt" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.0/core/cmp/trait.PartialOrd.html#method.lt" class="fn">lt</a>(&self, other: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.reference.html">&Rhs</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'>Tests less than (for <code>self</code> and <code>other</code>) and is used by the <code><</code> operator. <a href="https://doc.rust-lang.org/1.85.0/core/cmp/trait.PartialOrd.html#method.lt">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.le" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.85.0/src/core/cmp.rs.html#1353">Source</a></span><a href="#method.le" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.0/core/cmp/trait.PartialOrd.html#method.le" class="fn">le</a>(&self, other: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.reference.html">&Rhs</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'>Tests less than or equal to (for <code>self</code> and <code>other</code>) and is used by the
<code><=</code> operator. <a href="https://doc.rust-lang.org/1.85.0/core/cmp/trait.PartialOrd.html#method.le">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.gt" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.85.0/src/core/cmp.rs.html#1371">Source</a></span><a href="#method.gt" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.0/core/cmp/trait.PartialOrd.html#method.gt" class="fn">gt</a>(&self, other: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.reference.html">&Rhs</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'>Tests greater than (for <code>self</code> and <code>other</code>) and is used by the <code>></code>
operator. <a href="https://doc.rust-lang.org/1.85.0/core/cmp/trait.PartialOrd.html#method.gt">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.ge" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.85.0/src/core/cmp.rs.html#1389">Source</a></span><a href="#method.ge" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.0/core/cmp/trait.PartialOrd.html#method.ge" class="fn">ge</a>(&self, other: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.reference.html">&Rhs</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'>Tests greater than or equal to (for <code>self</code> and <code>other</code>) and is used by
the <code>>=</code> operator. <a href="https://doc.rust-lang.org/1.85.0/core/cmp/trait.PartialOrd.html#method.ge">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Serialize-for-NaiveTime" class="impl"><a class="src rightside" href="../src/chrono/naive/time/serde.rs.html#8-15">Source</a><a href="#impl-Serialize-for-NaiveTime" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="../serde/ser/trait.Serialize.html" title="trait serde::ser::Serialize">Serialize</a> for <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.serialize" class="method trait-impl"><a class="src rightside" href="../src/chrono/naive/time/serde.rs.html#9-14">Source</a><a href="#method.serialize" class="anchor">§</a><h4 class="code-header">fn <a href="../serde/ser/trait.Serialize.html#tymethod.serialize" class="fn">serialize</a><S>(&self, serializer: S) -> <a class="enum" href="https://doc.rust-lang.org/1.85.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><S::<a class="associatedtype" href="../serde/ser/trait.Serializer.html#associatedtype.Ok" title="type serde::ser::Serializer::Ok">Ok</a>, S::<a class="associatedtype" href="../serde/ser/trait.Serializer.html#associatedtype.Error" title="type serde::ser::Serializer::Error">Error</a>><div class="where">where
S: <a class="trait" href="../serde/ser/trait.Serializer.html" title="trait serde::ser::Serializer">Serializer</a>,</div></h4></section></summary><div class='docblock'>Serialize this value into the given Serde serializer. <a href="../serde/ser/trait.Serialize.html#tymethod.serialize">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Sub%3CDuration%3E-for-NaiveTime" class="impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1352-1364">Source</a><a href="#impl-Sub%3CDuration%3E-for-NaiveTime" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/ops/arith/trait.Sub.html" title="trait core::ops::arith::Sub">Sub</a><<a class="struct" href="https://doc.rust-lang.org/1.85.0/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>> for <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h3><div class="docblock"><p>Subtract <code>std::time::Duration</code> from <code>NaiveTime</code>.</p>
</div></section></summary><div class="docblock"><p>This wraps around and never overflows or underflows.
In particular the subtraction ignores integral number of days.</p>
</div><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Output-4" class="associatedtype trait-impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1353">Source</a><a href="#associatedtype.Output-4" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.85.0/core/ops/arith/trait.Sub.html#associatedtype.Output" class="associatedtype">Output</a> = <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h4></section></summary><div class='docblock'>The resulting type after applying the <code>-</code> operator.</div></details><details class="toggle method-toggle" open><summary><section id="method.sub-1" class="method trait-impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1356-1363">Source</a><a href="#method.sub-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.0/core/ops/arith/trait.Sub.html#tymethod.sub" class="fn">sub</a>(self, rhs: <a class="struct" href="https://doc.rust-lang.org/1.85.0/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>) -> <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h4></section></summary><div class='docblock'>Performs the <code>-</code> operation. <a href="https://doc.rust-lang.org/1.85.0/core/ops/arith/trait.Sub.html#tymethod.sub">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Sub%3CFixedOffset%3E-for-NaiveTime" class="impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1381-1388">Source</a><a href="#impl-Sub%3CFixedOffset%3E-for-NaiveTime" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/ops/arith/trait.Sub.html" title="trait core::ops::arith::Sub">Sub</a><<a class="struct" href="struct.FixedOffset.html" title="struct chrono::FixedOffset">FixedOffset</a>> for <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h3><div class="docblock"><p>Subtract <code>FixedOffset</code> from <code>NaiveTime</code>.</p>
</div></section></summary><div class="docblock"><p>This wraps around and never overflows or underflows.
In particular the subtraction ignores integral number of days.</p>
</div><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Output-5" class="associatedtype trait-impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1382">Source</a><a href="#associatedtype.Output-5" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.85.0/core/ops/arith/trait.Sub.html#associatedtype.Output" class="associatedtype">Output</a> = <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h4></section></summary><div class='docblock'>The resulting type after applying the <code>-</code> operator.</div></details><details class="toggle method-toggle" open><summary><section id="method.sub-2" class="method trait-impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1385-1387">Source</a><a href="#method.sub-2" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.0/core/ops/arith/trait.Sub.html#tymethod.sub" class="fn">sub</a>(self, rhs: <a class="struct" href="struct.FixedOffset.html" title="struct chrono::FixedOffset">FixedOffset</a>) -> <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h4></section></summary><div class='docblock'>Performs the <code>-</code> operation. <a href="https://doc.rust-lang.org/1.85.0/core/ops/arith/trait.Sub.html#tymethod.sub">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Sub%3CTimeDelta%3E-for-NaiveTime" class="impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1328-1335">Source</a><a href="#impl-Sub%3CTimeDelta%3E-for-NaiveTime" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/ops/arith/trait.Sub.html" title="trait core::ops::arith::Sub">Sub</a><<a class="struct" href="struct.TimeDelta.html" title="struct chrono::TimeDelta">TimeDelta</a>> for <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h3><div class="docblock"><p>Subtract <code>TimeDelta</code> from <code>NaiveTime</code>.</p>
</div></section></summary><div class="docblock"><p>This wraps around and never overflows or underflows.
In particular the subtraction ignores integral number of days.
This is the same as addition with a negated <code>TimeDelta</code>.</p>
<p>As a part of Chrono’s <a href="struct.NaiveTime.html#leap-second-handling" title="struct chrono::NaiveTime">leap second handling</a>, the subtraction 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>
<h4 id="example-22"><a class="doc-anchor" href="#example-22">§</a>Example</h4>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{NaiveTime, TimeDelta};
<span class="kw">let </span>from_hmsm = |h, m, s, milli| NaiveTime::from_hms_milli_opt(h, m, s, milli).unwrap();
<span class="macro">assert_eq!</span>(from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) - TimeDelta::zero(), from_hmsm(<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>(from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) - TimeDelta::try_seconds(<span class="number">1</span>).unwrap(), from_hmsm(<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>(
from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) - TimeDelta::try_seconds(<span class="number">60 </span>+ <span class="number">5</span>).unwrap(),
from_hmsm(<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>(
from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) - TimeDelta::try_seconds(<span class="number">2 </span>* <span class="number">60 </span>* <span class="number">60 </span>+ <span class="number">6 </span>* <span class="number">60</span>).unwrap(),
from_hmsm(<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>(
from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) - TimeDelta::try_milliseconds(<span class="number">80</span>).unwrap(),
from_hmsm(<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>(
from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">950</span>) - TimeDelta::try_milliseconds(<span class="number">280</span>).unwrap(),
from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">670</span>)
);</code></pre></div>
<p>The subtraction wraps around.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) - TimeDelta::try_seconds(<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>).unwrap(), from_hmsm(<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>(from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>) - TimeDelta::try_days(<span class="number">800</span>).unwrap(), from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">0</span>));</code></pre></div>
<p>Leap seconds are handled, but the subtraction assumes that it is the only leap second happened.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>leap = from_hmsm(<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>(leap - TimeDelta::zero(), from_hmsm(<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>(leap - TimeDelta::try_milliseconds(<span class="number">200</span>).unwrap(), from_hmsm(<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>(leap - TimeDelta::try_milliseconds(<span class="number">500</span>).unwrap(), from_hmsm(<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>(leap - TimeDelta::try_seconds(<span class="number">60</span>).unwrap(), from_hmsm(<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>(leap - TimeDelta::try_days(<span class="number">1</span>).unwrap(), from_hmsm(<span class="number">3</span>, <span class="number">6</span>, <span class="number">0</span>, <span class="number">300</span>));</code></pre></div>
</div><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Output-3" class="associatedtype trait-impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1329">Source</a><a href="#associatedtype.Output-3" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.85.0/core/ops/arith/trait.Sub.html#associatedtype.Output" class="associatedtype">Output</a> = <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h4></section></summary><div class='docblock'>The resulting type after applying the <code>-</code> operator.</div></details><details class="toggle method-toggle" open><summary><section id="method.sub" class="method trait-impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1332-1334">Source</a><a href="#method.sub" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.0/core/ops/arith/trait.Sub.html#tymethod.sub" class="fn">sub</a>(self, rhs: <a class="struct" href="struct.TimeDelta.html" title="struct chrono::TimeDelta">TimeDelta</a>) -> <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h4></section></summary><div class='docblock'>Performs the <code>-</code> operation. <a href="https://doc.rust-lang.org/1.85.0/core/ops/arith/trait.Sub.html#tymethod.sub">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Sub-for-NaiveTime" class="impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1455-1462">Source</a><a href="#impl-Sub-for-NaiveTime" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/ops/arith/trait.Sub.html" title="trait core::ops::arith::Sub">Sub</a> for <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h3><div class="docblock"><p>Subtracts another <code>NaiveTime</code> from the current time.
Returns a <code>TimeDelta</code> within +/- 1 day.
This does not overflow or underflow at all.</p>
</div></section></summary><div class="docblock"><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>
<h4 id="example-23"><a class="doc-anchor" href="#example-23">§</a>Example</h4>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{NaiveTime, TimeDelta};
<span class="kw">let </span>from_hmsm = |h, m, s, milli| NaiveTime::from_hms_milli_opt(h, m, s, milli).unwrap();
<span class="macro">assert_eq!</span>(from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>) - from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>), TimeDelta::zero());
<span class="macro">assert_eq!</span>(
from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>) - from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">875</span>),
TimeDelta::try_milliseconds(<span class="number">25</span>).unwrap()
);
<span class="macro">assert_eq!</span>(
from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>) - from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">925</span>),
TimeDelta::try_milliseconds(<span class="number">975</span>).unwrap()
);
<span class="macro">assert_eq!</span>(
from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>) - from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">0</span>, <span class="number">900</span>),
TimeDelta::try_seconds(<span class="number">7</span>).unwrap()
);
<span class="macro">assert_eq!</span>(
from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>) - from_hmsm(<span class="number">3</span>, <span class="number">0</span>, <span class="number">7</span>, <span class="number">900</span>),
TimeDelta::try_seconds(<span class="number">5 </span>* <span class="number">60</span>).unwrap()
);
<span class="macro">assert_eq!</span>(
from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>) - from_hmsm(<span class="number">0</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>),
TimeDelta::try_seconds(<span class="number">3 </span>* <span class="number">3600</span>).unwrap()
);
<span class="macro">assert_eq!</span>(
from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>) - from_hmsm(<span class="number">4</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>),
TimeDelta::try_seconds(-<span class="number">3600</span>).unwrap()
);
<span class="macro">assert_eq!</span>(
from_hmsm(<span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">900</span>) - from_hmsm(<span class="number">2</span>, <span class="number">4</span>, <span class="number">6</span>, <span class="number">800</span>),
TimeDelta::try_seconds(<span class="number">3600 </span>+ <span class="number">60 </span>+ <span class="number">1</span>).unwrap() + TimeDelta::try_milliseconds(<span class="number">100</span>).unwrap()
);</code></pre></div>
<p>Leap seconds are handled, but the subtraction assumes that
there were no other leap seconds happened.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(from_hmsm(<span class="number">3</span>, <span class="number">0</span>, <span class="number">59</span>, <span class="number">1_000</span>) - from_hmsm(<span class="number">3</span>, <span class="number">0</span>, <span class="number">59</span>, <span class="number">0</span>), TimeDelta::try_seconds(<span class="number">1</span>).unwrap());
<span class="macro">assert_eq!</span>(from_hmsm(<span class="number">3</span>, <span class="number">0</span>, <span class="number">59</span>, <span class="number">1_500</span>) - from_hmsm(<span class="number">3</span>, <span class="number">0</span>, <span class="number">59</span>, <span class="number">0</span>),
TimeDelta::try_milliseconds(<span class="number">1500</span>).unwrap());
<span class="macro">assert_eq!</span>(from_hmsm(<span class="number">3</span>, <span class="number">0</span>, <span class="number">59</span>, <span class="number">1_000</span>) - from_hmsm(<span class="number">3</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>), TimeDelta::try_seconds(<span class="number">60</span>).unwrap());
<span class="macro">assert_eq!</span>(from_hmsm(<span class="number">3</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>) - from_hmsm(<span class="number">2</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">1_000</span>), TimeDelta::try_seconds(<span class="number">1</span>).unwrap());
<span class="macro">assert_eq!</span>(from_hmsm(<span class="number">3</span>, <span class="number">0</span>, <span class="number">59</span>, <span class="number">1_000</span>) - from_hmsm(<span class="number">2</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">1_000</span>),
TimeDelta::try_seconds(<span class="number">61</span>).unwrap());</code></pre></div>
</div><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Output-6" class="associatedtype trait-impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1456">Source</a><a href="#associatedtype.Output-6" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.85.0/core/ops/arith/trait.Sub.html#associatedtype.Output" class="associatedtype">Output</a> = <a class="struct" href="struct.TimeDelta.html" title="struct chrono::TimeDelta">TimeDelta</a></h4></section></summary><div class='docblock'>The resulting type after applying the <code>-</code> operator.</div></details><details class="toggle method-toggle" open><summary><section id="method.sub-3" class="method trait-impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1459-1461">Source</a><a href="#method.sub-3" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.0/core/ops/arith/trait.Sub.html#tymethod.sub" class="fn">sub</a>(self, rhs: <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a>) -> <a class="struct" href="struct.TimeDelta.html" title="struct chrono::TimeDelta">TimeDelta</a></h4></section></summary><div class='docblock'>Performs the <code>-</code> operation. <a href="https://doc.rust-lang.org/1.85.0/core/ops/arith/trait.Sub.html#tymethod.sub">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-SubAssign%3CDuration%3E-for-NaiveTime" class="impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1370-1375">Source</a><a href="#impl-SubAssign%3CDuration%3E-for-NaiveTime" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/ops/arith/trait.SubAssign.html" title="trait core::ops::arith::SubAssign">SubAssign</a><<a class="struct" href="https://doc.rust-lang.org/1.85.0/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>> for <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h3><div class="docblock"><p>Subtract-assign <code>std::time::Duration</code> from <code>NaiveTime</code>.</p>
</div></section></summary><div class="docblock"><p>This wraps around and never overflows or underflows.
In particular the subtraction ignores integral number of days.</p>
</div><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.sub_assign-1" class="method trait-impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1372-1374">Source</a><a href="#method.sub_assign-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.0/core/ops/arith/trait.SubAssign.html#tymethod.sub_assign" class="fn">sub_assign</a>(&mut self, rhs: <a class="struct" href="https://doc.rust-lang.org/1.85.0/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>)</h4></section></summary><div class='docblock'>Performs the <code>-=</code> operation. <a href="https://doc.rust-lang.org/1.85.0/core/ops/arith/trait.SubAssign.html#tymethod.sub_assign">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-SubAssign%3CTimeDelta%3E-for-NaiveTime" class="impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1341-1346">Source</a><a href="#impl-SubAssign%3CTimeDelta%3E-for-NaiveTime" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/ops/arith/trait.SubAssign.html" title="trait core::ops::arith::SubAssign">SubAssign</a><<a class="struct" href="struct.TimeDelta.html" title="struct chrono::TimeDelta">TimeDelta</a>> for <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h3><div class="docblock"><p>Subtract-assign <code>TimeDelta</code> from <code>NaiveTime</code>.</p>
</div></section></summary><div class="docblock"><p>This wraps around and never overflows or underflows.
In particular the subtraction ignores integral number of days.</p>
</div><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.sub_assign" class="method trait-impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1343-1345">Source</a><a href="#method.sub_assign" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.0/core/ops/arith/trait.SubAssign.html#tymethod.sub_assign" class="fn">sub_assign</a>(&mut self, rhs: <a class="struct" href="struct.TimeDelta.html" title="struct chrono::TimeDelta">TimeDelta</a>)</h4></section></summary><div class='docblock'>Performs the <code>-=</code> operation. <a href="https://doc.rust-lang.org/1.85.0/core/ops/arith/trait.SubAssign.html#tymethod.sub_assign">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Timelike-for-NaiveTime" class="impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#902-1137">Source</a><a href="#impl-Timelike-for-NaiveTime" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.Timelike.html" title="trait chrono::Timelike">Timelike</a> for <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.hour" class="method trait-impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#914-916">Source</a><a href="#method.hour" class="anchor">§</a><h4 class="code-header">fn <a href="trait.Timelike.html#tymethod.hour" class="fn">hour</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a></h4></section></summary><div class="docblock"><p>Returns the hour number from 0 to 23.</p>
<h5 id="example-12"><a class="doc-anchor" href="#example-12">§</a>Example</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{NaiveTime, Timelike};
<span class="macro">assert_eq!</span>(NaiveTime::from_hms_opt(<span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>).unwrap().hour(), <span class="number">0</span>);
<span class="macro">assert_eq!</span>(NaiveTime::from_hms_nano_opt(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">12_345_678</span>).unwrap().hour(), <span class="number">23</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.minute" class="method trait-impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#929-931">Source</a><a href="#method.minute" class="anchor">§</a><h4 class="code-header">fn <a href="trait.Timelike.html#tymethod.minute" class="fn">minute</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a></h4></section></summary><div class="docblock"><p>Returns the minute number from 0 to 59.</p>
<h5 id="example-13"><a class="doc-anchor" href="#example-13">§</a>Example</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{NaiveTime, Timelike};
<span class="macro">assert_eq!</span>(NaiveTime::from_hms_opt(<span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>).unwrap().minute(), <span class="number">0</span>);
<span class="macro">assert_eq!</span>(NaiveTime::from_hms_nano_opt(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">12_345_678</span>).unwrap().minute(), <span class="number">56</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.second" class="method trait-impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#957-959">Source</a><a href="#method.second" class="anchor">§</a><h4 class="code-header">fn <a href="trait.Timelike.html#tymethod.second" class="fn">second</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a></h4></section></summary><div class="docblock"><p>Returns the second number from 0 to 59.</p>
<h5 id="example-14"><a class="doc-anchor" href="#example-14">§</a>Example</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{NaiveTime, Timelike};
<span class="macro">assert_eq!</span>(NaiveTime::from_hms_opt(<span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>).unwrap().second(), <span class="number">0</span>);
<span class="macro">assert_eq!</span>(NaiveTime::from_hms_nano_opt(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">12_345_678</span>).unwrap().second(), <span class="number">4</span>);</code></pre></div>
<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>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>leap = NaiveTime::from_hms_milli_opt(<span class="number">23</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">1_000</span>).unwrap();
<span class="macro">assert_eq!</span>(leap.second(), <span class="number">59</span>);
<span class="macro">assert_eq!</span>(leap.format(<span class="string">"%H:%M:%S"</span>).to_string(), <span class="string">"23:59:60"</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.nanosecond-1" class="method trait-impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#990-992">Source</a><a href="#method.nanosecond-1" class="anchor">§</a><h4 class="code-header">fn <a href="trait.Timelike.html#tymethod.nanosecond" class="fn">nanosecond</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a></h4></section></summary><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>
<h5 id="example-15"><a class="doc-anchor" href="#example-15">§</a>Example</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{NaiveTime, Timelike};
<span class="macro">assert_eq!</span>(NaiveTime::from_hms_opt(<span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>).unwrap().nanosecond(), <span class="number">0</span>);
<span class="macro">assert_eq!</span>(
NaiveTime::from_hms_nano_opt(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">12_345_678</span>).unwrap().nanosecond(),
<span class="number">12_345_678
</span>);</code></pre></div>
<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>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>leap = NaiveTime::from_hms_milli_opt(<span class="number">23</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">1_000</span>).unwrap();
<span class="macro">assert_eq!</span>(leap.nanosecond(), <span class="number">1_000_000_000</span>);
<span class="macro">assert_eq!</span>(leap.format(<span class="string">"%H:%M:%S%.9f"</span>).to_string(), <span class="string">"23:59:60.000000000"</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.with_hour" class="method trait-impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1010-1016">Source</a><a href="#method.with_hour" class="anchor">§</a><h4 class="code-header">fn <a href="trait.Timelike.html#tymethod.with_hour" class="fn">with_hour</a>(&self, hour: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.85.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a>></h4></section></summary><div class="docblock"><p>Makes a new <code>NaiveTime</code> with the hour number changed.</p>
<h5 id="errors-5"><a class="doc-anchor" href="#errors-5">§</a>Errors</h5>
<p>Returns <code>None</code> if the value for <code>hour</code> is invalid.</p>
<h5 id="example-16"><a class="doc-anchor" href="#example-16">§</a>Example</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{NaiveTime, Timelike};
<span class="kw">let </span>dt = NaiveTime::from_hms_nano_opt(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">12_345_678</span>).unwrap();
<span class="macro">assert_eq!</span>(dt.with_hour(<span class="number">7</span>), <span class="prelude-val">Some</span>(NaiveTime::from_hms_nano_opt(<span class="number">7</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">12_345_678</span>).unwrap()));
<span class="macro">assert_eq!</span>(dt.with_hour(<span class="number">24</span>), <span class="prelude-val">None</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.with_minute" class="method trait-impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1037-1043">Source</a><a href="#method.with_minute" class="anchor">§</a><h4 class="code-header">fn <a href="trait.Timelike.html#tymethod.with_minute" class="fn">with_minute</a>(&self, min: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.85.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a>></h4></section></summary><div class="docblock"><p>Makes a new <code>NaiveTime</code> with the minute number changed.</p>
<h5 id="errors-6"><a class="doc-anchor" href="#errors-6">§</a>Errors</h5>
<p>Returns <code>None</code> if the value for <code>minute</code> is invalid.</p>
<h5 id="example-17"><a class="doc-anchor" href="#example-17">§</a>Example</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{NaiveTime, Timelike};
<span class="kw">let </span>dt = NaiveTime::from_hms_nano_opt(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">12_345_678</span>).unwrap();
<span class="macro">assert_eq!</span>(
dt.with_minute(<span class="number">45</span>),
<span class="prelude-val">Some</span>(NaiveTime::from_hms_nano_opt(<span class="number">23</span>, <span class="number">45</span>, <span class="number">4</span>, <span class="number">12_345_678</span>).unwrap())
);
<span class="macro">assert_eq!</span>(dt.with_minute(<span class="number">60</span>), <span class="prelude-val">None</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.with_second" class="method trait-impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1067-1073">Source</a><a href="#method.with_second" class="anchor">§</a><h4 class="code-header">fn <a href="trait.Timelike.html#tymethod.with_second" class="fn">with_second</a>(&self, sec: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.85.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a>></h4></section></summary><div class="docblock"><p>Makes a new <code>NaiveTime</code> with the second number changed.</p>
<p>As with the <a href="#method.second"><code>second</code></a> method,
the input range is restricted to 0 through 59.</p>
<h5 id="errors-7"><a class="doc-anchor" href="#errors-7">§</a>Errors</h5>
<p>Returns <code>None</code> if the value for <code>second</code> is invalid.</p>
<h5 id="example-18"><a class="doc-anchor" href="#example-18">§</a>Example</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{NaiveTime, Timelike};
<span class="kw">let </span>dt = NaiveTime::from_hms_nano_opt(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">12_345_678</span>).unwrap();
<span class="macro">assert_eq!</span>(
dt.with_second(<span class="number">17</span>),
<span class="prelude-val">Some</span>(NaiveTime::from_hms_nano_opt(<span class="number">23</span>, <span class="number">56</span>, <span class="number">17</span>, <span class="number">12_345_678</span>).unwrap())
);
<span class="macro">assert_eq!</span>(dt.with_second(<span class="number">60</span>), <span class="prelude-val">None</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.with_nanosecond" class="method trait-impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1109-1114">Source</a><a href="#method.with_nanosecond" class="anchor">§</a><h4 class="code-header">fn <a href="trait.Timelike.html#tymethod.with_nanosecond" class="fn">with_nanosecond</a>(&self, nano: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.85.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a>></h4></section></summary><div class="docblock"><p>Makes a new <code>NaiveTime</code> with nanoseconds since the whole non-leap second changed.</p>
<p>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>
<h5 id="errors-8"><a class="doc-anchor" href="#errors-8">§</a>Errors</h5>
<p>Returns <code>None</code> if <code>nanosecond >= 2,000,000,000</code>.</p>
<h5 id="example-19"><a class="doc-anchor" href="#example-19">§</a>Example</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{NaiveTime, Timelike};
<span class="kw">let </span>dt = NaiveTime::from_hms_nano_opt(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">12_345_678</span>).unwrap();
<span class="macro">assert_eq!</span>(
dt.with_nanosecond(<span class="number">333_333_333</span>),
<span class="prelude-val">Some</span>(NaiveTime::from_hms_nano_opt(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">333_333_333</span>).unwrap())
);
<span class="macro">assert_eq!</span>(dt.with_nanosecond(<span class="number">2_000_000_000</span>), <span class="prelude-val">None</span>);</code></pre></div>
<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 “non-sense” offset),
and therefore is allowed.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>dt = NaiveTime::from_hms_nano_opt(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">12_345_678</span>).unwrap();
<span class="kw">let </span>strange_leap_second = dt.with_nanosecond(<span class="number">1_333_333_333</span>).unwrap();
<span class="macro">assert_eq!</span>(strange_leap_second.nanosecond(), <span class="number">1_333_333_333</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.num_seconds_from_midnight-1" class="method trait-impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#1134-1136">Source</a><a href="#method.num_seconds_from_midnight-1" class="anchor">§</a><h4 class="code-header">fn <a href="trait.Timelike.html#method.num_seconds_from_midnight" class="fn">num_seconds_from_midnight</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a></h4></section></summary><div class="docblock"><p>Returns the number of non-leap seconds past the last midnight.</p>
<h5 id="example-20"><a class="doc-anchor" href="#example-20">§</a>Example</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{NaiveTime, Timelike};
<span class="macro">assert_eq!</span>(NaiveTime::from_hms_opt(<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>).unwrap().num_seconds_from_midnight(), <span class="number">3723</span>);
<span class="macro">assert_eq!</span>(
NaiveTime::from_hms_nano_opt(<span class="number">23</span>, <span class="number">56</span>, <span class="number">4</span>, <span class="number">12_345_678</span>).unwrap().num_seconds_from_midnight(),
<span class="number">86164
</span>);
<span class="macro">assert_eq!</span>(
NaiveTime::from_hms_milli_opt(<span class="number">23</span>, <span class="number">59</span>, <span class="number">59</span>, <span class="number">1_000</span>).unwrap().num_seconds_from_midnight(),
<span class="number">86399
</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.hour12" class="method trait-impl"><a class="src rightside" href="../src/chrono/traits.rs.html#278-285">Source</a><a href="#method.hour12" class="anchor">§</a><h4 class="code-header">fn <a href="trait.Timelike.html#method.hour12" class="fn">hour12</a>(&self) -> (<a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.bool.html">bool</a>, <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u32.html">u32</a>)</h4></section></summary><div class='docblock'>Returns the hour number from 1 to 12 with a boolean flag,
which is false for AM and true for PM.</div></details></div></details><section id="impl-Copy-for-NaiveTime" class="impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#212">Source</a><a href="#impl-Copy-for-NaiveTime" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> for <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h3></section><section id="impl-Eq-for-NaiveTime" class="impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#212">Source</a><a href="#impl-Eq-for-NaiveTime" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> for <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h3></section><section id="impl-StructuralPartialEq-for-NaiveTime" class="impl"><a class="src rightside" href="../src/chrono/naive/time/mod.rs.html#212">Source</a><a href="#impl-StructuralPartialEq-for-NaiveTime" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/marker/trait.StructuralPartialEq.html" title="trait core::marker::StructuralPartialEq">StructuralPartialEq</a> for <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h3></section></div><h2 id="synthetic-implementations" class="section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor">§</a></h2><div id="synthetic-implementations-list"><section id="impl-Freeze-for-NaiveTime" class="impl"><a href="#impl-Freeze-for-NaiveTime" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/marker/trait.Freeze.html" title="trait core::marker::Freeze">Freeze</a> for <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h3></section><section id="impl-RefUnwindSafe-for-NaiveTime" class="impl"><a href="#impl-RefUnwindSafe-for-NaiveTime" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h3></section><section id="impl-Send-for-NaiveTime" class="impl"><a href="#impl-Send-for-NaiveTime" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h3></section><section id="impl-Sync-for-NaiveTime" class="impl"><a href="#impl-Sync-for-NaiveTime" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h3></section><section id="impl-Unpin-for-NaiveTime" class="impl"><a href="#impl-Unpin-for-NaiveTime" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h3></section><section id="impl-UnwindSafe-for-NaiveTime" class="impl"><a href="#impl-UnwindSafe-for-NaiveTime" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="struct" href="struct.NaiveTime.html" title="struct chrono::NaiveTime">NaiveTime</a></h3></section></div><h2 id="blanket-implementations" class="section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor">§</a></h2><div id="blanket-implementations-list"><details class="toggle implementors-toggle"><summary><section id="impl-Any-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.85.0/src/core/any.rs.html#138">Source</a><a href="#impl-Any-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T<div class="where">where
T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/1.85.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.85.0/src/core/any.rs.html#139">Source</a><a href="#method.type_id" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.0/core/any/trait.Any.html#tymethod.type_id" class="fn">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/1.85.0/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></h4></section></summary><div class='docblock'>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/1.85.0/core/any/trait.Any.html#tymethod.type_id">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.85.0/src/core/borrow.rs.html#209">Source</a><a href="#impl-Borrow%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T<div class="where">where
T: ?<a class="trait" href="https://doc.rust-lang.org/1.85.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.85.0/src/core/borrow.rs.html#211">Source</a><a href="#method.borrow" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.0/core/borrow/trait.Borrow.html#tymethod.borrow" class="fn">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.reference.html">&T</a></h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.85.0/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.85.0/src/core/borrow.rs.html#217">Source</a><a href="#impl-BorrowMut%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T<div class="where">where
T: ?<a class="trait" href="https://doc.rust-lang.org/1.85.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.85.0/src/core/borrow.rs.html#218">Source</a><a href="#method.borrow_mut" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.0/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fn">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.reference.html">&mut T</a></h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.85.0/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-CloneToUninit-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.85.0/src/core/clone.rs.html#273">Source</a><a href="#impl-CloneToUninit-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/clone/trait.CloneToUninit.html" title="trait core::clone::CloneToUninit">CloneToUninit</a> for T<div class="where">where
T: <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.clone_to_uninit" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.85.0/src/core/clone.rs.html#275">Source</a><a href="#method.clone_to_uninit" class="anchor">§</a><h4 class="code-header">unsafe fn <a href="https://doc.rust-lang.org/1.85.0/core/clone/trait.CloneToUninit.html#tymethod.clone_to_uninit" class="fn">clone_to_uninit</a>(&self, dst: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.pointer.html">*mut </a><a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u8.html">u8</a>)</h4></section></summary><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>clone_to_uninit</code>)</span></div></span><div class='docblock'>Performs copy-assignment from <code>self</code> to <code>dst</code>. <a href="https://doc.rust-lang.org/1.85.0/core/clone/trait.CloneToUninit.html#tymethod.clone_to_uninit">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.85.0/src/core/convert/mod.rs.html#767">Source</a><a href="#impl-From%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.85.0/src/core/convert/mod.rs.html#770">Source</a><a href="#method.from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.0/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(t: T) -> T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p>
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.85.0/src/core/convert/mod.rs.html#750-752">Source</a><a href="#impl-Into%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.85.0/src/core/convert/mod.rs.html#760">Source</a><a href="#method.into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.0/core/convert/trait.Into.html#tymethod.into" class="fn">into</a>(self) -> U</h4></section></summary><div class="docblock"><p>Calls <code>U::from(self)</code>.</p>
<p>That is, this conversion is whatever the implementation of
<code><a href="https://doc.rust-lang.org/1.85.0/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for U</code> chooses to do.</p>
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-SubsecRound-for-T" class="impl"><a class="src rightside" href="../src/chrono/round.rs.html#52-80">Source</a><a href="#impl-SubsecRound-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="round/trait.SubsecRound.html" title="trait chrono::round::SubsecRound">SubsecRound</a> for T<div class="where">where
T: <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/ops/arith/trait.Add.html" title="trait core::ops::arith::Add">Add</a><<a class="struct" href="struct.TimeDelta.html" title="struct chrono::TimeDelta">TimeDelta</a>, Output = T> + <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/ops/arith/trait.Sub.html" title="trait core::ops::arith::Sub">Sub</a><<a class="struct" href="struct.TimeDelta.html" title="struct chrono::TimeDelta">TimeDelta</a>, Output = T> + <a class="trait" href="trait.Timelike.html" title="trait chrono::Timelike">Timelike</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.round_subsecs" class="method trait-impl"><a class="src rightside" href="../src/chrono/round.rs.html#56-69">Source</a><a href="#method.round_subsecs" class="anchor">§</a><h4 class="code-header">fn <a href="round/trait.SubsecRound.html#tymethod.round_subsecs" class="fn">round_subsecs</a>(self, digits: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u16.html">u16</a>) -> T</h4></section></summary><div class='docblock'>Return a copy rounded to the specified number of subsecond digits. With
9 or more digits, self is returned unmodified. Halfway values are
rounded up (away from zero). <a href="round/trait.SubsecRound.html#tymethod.round_subsecs">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.trunc_subsecs" class="method trait-impl"><a class="src rightside" href="../src/chrono/round.rs.html#71-79">Source</a><a href="#method.trunc_subsecs" class="anchor">§</a><h4 class="code-header">fn <a href="round/trait.SubsecRound.html#tymethod.trunc_subsecs" class="fn">trunc_subsecs</a>(self, digits: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.u16.html">u16</a>) -> T</h4></section></summary><div class='docblock'>Return a copy truncated to the specified number of subsecond
digits. With 9 or more digits, self is returned unmodified. <a href="round/trait.SubsecRound.html#tymethod.trunc_subsecs">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-ToOwned-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.85.0/src/alloc/borrow.rs.html#82-84">Source</a><a href="#impl-ToOwned-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.85.0/alloc/borrow/trait.ToOwned.html" title="trait alloc::borrow::ToOwned">ToOwned</a> for T<div class="where">where
T: <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Owned" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.85.0/src/alloc/borrow.rs.html#86">Source</a><a href="#associatedtype.Owned" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.85.0/alloc/borrow/trait.ToOwned.html#associatedtype.Owned" class="associatedtype">Owned</a> = T</h4></section></summary><div class='docblock'>The resulting type after obtaining ownership.</div></details><details class="toggle method-toggle" open><summary><section id="method.to_owned" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.85.0/src/alloc/borrow.rs.html#87">Source</a><a href="#method.to_owned" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.0/alloc/borrow/trait.ToOwned.html#tymethod.to_owned" class="fn">to_owned</a>(&self) -> T</h4></section></summary><div class='docblock'>Creates owned data from borrowed data, usually by cloning. <a href="https://doc.rust-lang.org/1.85.0/alloc/borrow/trait.ToOwned.html#tymethod.to_owned">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.clone_into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.85.0/src/alloc/borrow.rs.html#91">Source</a><a href="#method.clone_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.0/alloc/borrow/trait.ToOwned.html#method.clone_into" class="fn">clone_into</a>(&self, target: <a class="primitive" href="https://doc.rust-lang.org/1.85.0/std/primitive.reference.html">&mut T</a>)</h4></section></summary><div class='docblock'>Uses borrowed data to replace owned data, usually by cloning. <a href="https://doc.rust-lang.org/1.85.0/alloc/borrow/trait.ToOwned.html#method.clone_into">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-ToString-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.85.0/src/alloc/string.rs.html#2677">Source</a><a href="#impl-ToString-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.85.0/alloc/string/trait.ToString.html" title="trait alloc::string::ToString">ToString</a> for T<div class="where">where
T: <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.85.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.to_string" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.85.0/src/alloc/string.rs.html#2679">Source</a><a href="#method.to_string" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.0/alloc/string/trait.ToString.html#tymethod.to_string" class="fn">to_string</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/1.85.0/alloc/string/struct.String.html" title="struct alloc::string::String">String</a></h4></section></summary><div class='docblock'>Converts the given value to a <code>String</code>. <a href="https://doc.rust-lang.org/1.85.0/alloc/string/trait.ToString.html#tymethod.to_string">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.85.0/src/core/convert/mod.rs.html#807-809">Source</a><a href="#impl-TryFrom%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.85.0/src/core/convert/mod.rs.html#811">Source</a><a href="#associatedtype.Error-1" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.85.0/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/1.85.0/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.85.0/src/core/convert/mod.rs.html#814">Source</a><a href="#method.try_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.0/core/convert/trait.TryFrom.html#tymethod.try_from" class="fn">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/1.85.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.85.0/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.85.0/src/core/convert/mod.rs.html#792-794">Source</a><a href="#impl-TryInto%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.85.0/src/core/convert/mod.rs.html#796">Source</a><a href="#associatedtype.Error" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.85.0/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.85.0/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.85.0/src/core/convert/mod.rs.html#799">Source</a><a href="#method.try_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.0/core/convert/trait.TryInto.html#tymethod.try_into" class="fn">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.85.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/1.85.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.85.0/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><section id="impl-DeserializeOwned-for-T" class="impl"><a class="src rightside" href="../src/serde/de/mod.rs.html#614">Source</a><a href="#impl-DeserializeOwned-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="../serde/de/trait.DeserializeOwned.html" title="trait serde::de::DeserializeOwned">DeserializeOwned</a> for T<div class="where">where
T: for<'de> <a class="trait" href="../serde/de/trait.Deserialize.html" title="trait serde::de::Deserialize">Deserialize</a><'de>,</div></h3></section></div></section></div></main></body></html>