-
Notifications
You must be signed in to change notification settings - Fork 156
/
duration.html
2016 lines (1949 loc) · 116 KB
/
duration.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
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html>
<meta charset="utf8">
<emu-clause id="sec-temporal-duration-objects">
<h1>Temporal.Duration Objects</h1>
<p>
A Temporal.Duration object describes the difference in elapsed time between
two other Temporal objects of the same type: Instant, PlainDate,
PlainDateTime, PlainTime, PlainYearMonth, or ZonedDateTime. Objects of this
type are only created via the <i>.since()</i> and <i>.until()</i> methods of
these objects.
</p>
<emu-clause id="sec-temporal-duration-constructor">
<h1>The Temporal.Duration Constructor</h1>
<p>The Temporal.Duration constructor:</p>
<ul>
<li>
creates and initializes a new Temporal.Duration object when called as a constructor.
</li>
<li>
is not intended to be called as a function and will throw an exception when called in that manner.
</li>
<li>
may be used as the value of an `extends` clause of a class definition.
Subclass constructors that intend to inherit the specified Temporal.Duration behaviour must
include a super call to the %Temporal.Duration% constructor to create and initialize subclass
instances with the necessary internal slots.
</li>
</ul>
<emu-clause id="sec-temporal.duration">
<h1>Temporal.Duration ( [ _years_ [ , _months_ [ , _weeks_ [ , _days_ [ , _hours_ [ , _minutes_ [ , _seconds_ [ , _milliseconds_ [ , _microseconds_ [ , _nanoseconds_ ] ] ] ] ] ] ] ] ] ] )</h1>
<p>
The `Temporal.Duration` function performs the following steps when called:
</p>
<emu-alg>
1. If NewTarget is *undefined*, then
1. Throw a *TypeError* exception.
1. If _years_ is *undefined*, let _y_ be 0; else let _y_ be ? ToIntegerIfIntegral(_years_).
1. If _months_ is *undefined*, let _mo_ be 0; else let _mo_ be ? ToIntegerIfIntegral(_months_).
1. If _weeks_ is *undefined*, let _w_ be 0; else let _w_ be ? ToIntegerIfIntegral(_weeks_).
1. If _days_ is *undefined*, let _d_ be 0; else let _d_ be ? ToIntegerIfIntegral(_days_).
1. If _hours_ is *undefined*, let _h_ be 0; else let _h_ be ? ToIntegerIfIntegral(_hours_).
1. If _minutes_ is *undefined*, let _m_ be 0; else let _m_ be ? ToIntegerIfIntegral(_minutes_).
1. If _seconds_ is *undefined*, let _s_ be 0; else let _s_ be ? ToIntegerIfIntegral(_seconds_).
1. If _milliseconds_ is *undefined*, let _ms_ be 0; else let _ms_ be ? ToIntegerIfIntegral(_milliseconds_).
1. If _microseconds_ is *undefined*, let _mis_ be 0; else let _mis_ be ? ToIntegerIfIntegral(_microseconds_).
1. If _nanoseconds_ is *undefined*, let _ns_ be 0; else let _ns_ be ? ToIntegerIfIntegral(_nanoseconds_).
1. Return ? CreateTemporalDuration(_y_, _mo_, _w_, _d_, _h_, _m_, _s_, _ms_, _mis_, _ns_, NewTarget).
</emu-alg>
</emu-clause>
</emu-clause>
<emu-clause id="sec-properties-of-the-temporal-duration-constructor">
<h1>Properties of the Temporal.Duration Constructor</h1>
<p>
The value of the [[Prototype]] internal slot of the Temporal.Duration
constructor is the intrinsic object %Function.prototype%.
</p>
<p>The Temporal.Duration constructor has the following properties:</p>
<emu-clause id="sec-temporal.duration.prototype">
<h1>Temporal.Duration.prototype</h1>
<p>
The initial value of `Temporal.Duration.prototype` is
%Temporal.Duration.prototype%.
</p>
<p>
This property has the attributes { [[Writable]]: *false*, [[Enumerable]]:
*false*, [[Configurable]]: *false* }.
</p>
</emu-clause>
<emu-clause id="sec-temporal.duration.from">
<h1>Temporal.Duration.from ( _item_ )</h1>
<p>
The `Temporal.Duration.from` function performs the following steps when called:
</p>
<emu-alg>
1. If Type(_item_) is Object and _item_ has an [[InitializedTemporalDuration]] internal slot, then
1. Return ! CreateTemporalDuration(_item_.[[Years]], _item_.[[Months]], _item_.[[Weeks]], _item_.[[Days]], _item_.[[Hours]], _item_.[[Minutes]], _item_.[[Seconds]], _item_.[[Milliseconds]], _item_.[[Microseconds]], _item_.[[Nanoseconds]]).
1. Return ? ToTemporalDuration(_item_).
</emu-alg>
</emu-clause>
<emu-clause id="sec-temporal.duration.compare">
<h1>Temporal.Duration.compare ( _one_, _two_ [ , _options_ ] )</h1>
<p>
The `Temporal.Duration.compare` function performs the following steps when called:
</p>
<emu-alg>
1. Set _one_ to ? ToTemporalDuration(_one_).
1. Set _two_ to ? ToTemporalDuration(_two_).
1. Set _options_ to ? GetOptionsObject(_options_).
1. If _one_.[[Years]] = _two_.[[Years]], and _one_.[[Months]] = _two_.[[Months]], and _one_.[[Weeks]] = _two_.[[Weeks]], and _one_.[[Days]] = _two_.[[Days]], and _one_.[[Hours]] = _two_.[[Hours]], and _one_.[[Minutes]] = _two_.[[Minutes]], and _one_.[[Seconds]] = _two_.[[Seconds]], and _one_.[[Millieconds]] = _two_.[[Millieconds]], and _one_.[[Microseconds]] = _two_.[[Microseconds]], and _one_.[[Nanoseconds]] = _two_.[[Nanoseconds]], then
1. Return *+0*<sub>𝔽</sub>.
1. Let _relativeToRecord_ be ? ToRelativeTemporalObject(_options_).
1. Let _zonedRelativeTo_ be _relativeToRecord_.[[ZonedRelativeTo]].
1. Let _plainRelativeTo_ be _relativeToRecord_.[[PlainRelativeTo]].
1. Let _calendarUnitsPresent_ be *false*.
1. If _one_.[[Years]] ≠ 0, or _two_.[[Years]] ≠ 0, or _one_.[[Months]] ≠ 0, or _two_.[[Months]] ≠ 0, or _one_.[[Weeks]] ≠ 0, or _two_.[[Weeks]] ≠ 0, set _calendarUnitsPresent_ to *true*.
1. If _zonedRelativeTo_ is not *undefined*, and either _calendarUnitsPresent_ is *true*, or _one_.[[Days]] ≠ 0, or _two_.[[Days]] ≠ 0, then
1. Let _timeZone_ be _zonedRelativeTo_.[[TimeZone]].
1. Let _calendar_ be _zonedRelativeTo_.[[Calendar]].
1. Let _instant_ be ! CreateTemporalInstant(_zonedRelativeTo_.[[Nanoseconds]]).
1. Let _precalculatedPlainDateTime_ be ? GetPlainDateTimeFor(_timeZone_, _instant_, _calendar_).
1. Let _after1_ be ? AddZonedDateTime(_zonedRelativeTo_.[[Nanoseconds]], _timeZone_, _calendar_, _one_.[[Years]], _one_.[[Months]], _one_.[[Weeks]], _one_.[[Days]], _one_.[[Hours]], _one_.[[Minutes]], _one_.[[Seconds]], _one_.[[Milliseconds]], _one_.[[Microseconds]], _one_.[[Nanoseconds]], _precalculatedPlainDateTime_).
1. Let _after2_ be ? AddZonedDateTime(_zonedRelativeTo_.[[Nanoseconds]], _timeZone_, _calendar_, _two_.[[Years]], _two_.[[Months]], _two_.[[Weeks]], _two_.[[Days]], _two_.[[Hours]], _two_.[[Minutes]], _two_.[[Seconds]], _two_.[[Milliseconds]], _two_.[[Microseconds]], _two_.[[Nanoseconds]], _precalculatedPlainDateTime_).
1. If _after1_ > _after2_, return *1*<sub>𝔽</sub>.
1. If _after1_ < _after2_, return *-1*<sub>𝔽</sub>.
1. Return *+0*<sub>𝔽</sub>.
1. If _calendarUnitsPresent_ is *true*, then
1. Let _unbalanceResult1_ be ? UnbalanceDateDurationRelative(_one_.[[Years]], _one_.[[Months]], _one_.[[Weeks]], _one_.[[Days]], *"day"*, _plainRelativeTo_).
1. Let _unbalanceResult2_ be ? UnbalanceDateDurationRelative(_two_.[[Years]], _two_.[[Months]], _two_.[[Weeks]], _two_.[[Days]], *"day"*, _plainRelativeTo_).
1. Let _days1_ be _unbalanceResult1_.[[Days]].
1. Let _days2_ be _unbalanceResult2_.[[Days]].
1. Else,
1. Let _days1_ be _one_.[[Days]].
1. Let _days2_ be _two_.[[Days]].
1. Let _hours1_ be _one_.[[Hours]] + _days1_ × 24.
1. Let _hours2_ be _two_.[[Hours]] + _days2_ × 24.
1. Let _ns1_ be TotalDurationNanoseconds(_hours1_, _one_.[[Minutes]], _one_.[[Seconds]], _one_.[[Milliseconds]], _one_.[[Microseconds]], _one_.[[Nanoseconds]]).
1. Let _ns2_ be TotalDurationNanoseconds(_hours2_, _two_.[[Minutes]], _two_.[[Seconds]], _two_.[[Milliseconds]], _two_.[[Microseconds]], _two_.[[Nanoseconds]]).
1. If _ns1_ > _ns2_, return *1*<sub>𝔽</sub>.
1. If _ns1_ < _ns2_, return *-1*<sub>𝔽</sub>.
1. Return *+0*<sub>𝔽</sub>.
</emu-alg>
</emu-clause>
</emu-clause>
<emu-clause id="sec-properties-of-the-temporal-duration-prototype-object">
<h1>Properties of the Temporal.Duration Prototype Object</h1>
<p>The Temporal.Duration prototype object</p>
<ul>
<li>is itself an ordinary object.</li>
<li>is not a Temporal.Duration instance and doesn't have an [[InitializedTemporalDuration]] internal slot.</li>
<li>has a [[Prototype]] internal slot whose value is %Object.prototype%.</li>
</ul>
<emu-clause id="sec-temporal.duration.prototype.constructor">
<h1>Temporal.Duration.prototype.constructor</h1>
<p>The initial value of `Temporal.Duration.prototype.constructor` is %Temporal.Duration%.</p>
</emu-clause>
<emu-clause id="sec-temporal.duration.prototype-@@tostringtag">
<h1>Temporal.Duration.prototype[ @@toStringTag ]</h1>
<p>The initial value of the @@toStringTag property is the string value *"Temporal.Duration"*.</p>
<p>This property has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *true* }.</p>
</emu-clause>
<emu-clause id="sec-get-temporal.duration.prototype.years">
<h1>get Temporal.Duration.prototype.years</h1>
<p>
`Temporal.Duration.prototype.years` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
</p>
<emu-alg>
1. Let _duration_ be the *this* value.
1. Perform ? RequireInternalSlot(_duration_, [[InitializedTemporalDuration]]).
1. Return 𝔽(_duration_.[[Years]]).
</emu-alg>
</emu-clause>
<emu-clause id="sec-get-temporal.duration.prototype.months">
<h1>get Temporal.Duration.prototype.months</h1>
<p>
`Temporal.Duration.prototype.months` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
</p>
<emu-alg>
1. Let _duration_ be the *this* value.
1. Perform ? RequireInternalSlot(_duration_, [[InitializedTemporalDuration]]).
1. Return 𝔽(_duration_.[[Months]]).
</emu-alg>
</emu-clause>
<emu-clause id="sec-get-temporal.duration.prototype.weeks">
<h1>get Temporal.Duration.prototype.weeks</h1>
<p>
`Temporal.Duration.prototype.weeks` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
</p>
<emu-alg>
1. Let _duration_ be the *this* value.
1. Perform ? RequireInternalSlot(_duration_, [[InitializedTemporalDuration]]).
1. Return 𝔽(_duration_.[[Weeks]]).
</emu-alg>
</emu-clause>
<emu-clause id="sec-get-temporal.duration.prototype.days">
<h1>get Temporal.Duration.prototype.days</h1>
<p>
`Temporal.Duration.prototype.days` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
</p>
<emu-alg>
1. Let _duration_ be the *this* value.
1. Perform ? RequireInternalSlot(_duration_, [[InitializedTemporalDuration]]).
1. Return 𝔽(_duration_.[[Days]]).
</emu-alg>
</emu-clause>
<emu-clause id="sec-get-temporal.duration.prototype.hours">
<h1>get Temporal.Duration.prototype.hours</h1>
<p>
`Temporal.Duration.prototype.hours` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
</p>
<emu-alg>
1. Let _duration_ be the *this* value.
1. Perform ? RequireInternalSlot(_duration_, [[InitializedTemporalDuration]]).
1. Return 𝔽(_duration_.[[Hours]]).
</emu-alg>
</emu-clause>
<emu-clause id="sec-get-temporal.duration.prototype.minutes">
<h1>get Temporal.Duration.prototype.minutes</h1>
<p>
`Temporal.Duration.prototype.minutes` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
</p>
<emu-alg>
1. Let _duration_ be the *this* value.
1. Perform ? RequireInternalSlot(_duration_, [[InitializedTemporalDuration]]).
1. Return 𝔽(_duration_.[[Minutes]]).
</emu-alg>
</emu-clause>
<emu-clause id="sec-get-temporal.duration.prototype.seconds">
<h1>get Temporal.Duration.prototype.seconds</h1>
<p>
`Temporal.Duration.prototype.seconds` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
</p>
<emu-alg>
1. Let _duration_ be the *this* value.
1. Perform ? RequireInternalSlot(_duration_, [[InitializedTemporalDuration]]).
1. Return 𝔽(_duration_.[[Seconds]]).
</emu-alg>
</emu-clause>
<emu-clause id="sec-get-temporal.duration.prototype.milliseconds">
<h1>get Temporal.Duration.prototype.milliseconds</h1>
<p>
`Temporal.Duration.prototype.milliseconds` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
</p>
<emu-alg>
1. Let _duration_ be the *this* value.
1. Perform ? RequireInternalSlot(_duration_, [[InitializedTemporalDuration]]).
1. Return 𝔽(_duration_.[[Milliseconds]]).
</emu-alg>
</emu-clause>
<emu-clause id="sec-get-temporal.duration.prototype.microseconds">
<h1>get Temporal.Duration.prototype.microseconds</h1>
<p>
`Temporal.Duration.prototype.microseconds` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
</p>
<emu-alg>
1. Let _duration_ be the *this* value.
1. Perform ? RequireInternalSlot(_duration_, [[InitializedTemporalDuration]]).
1. Return 𝔽(_duration_.[[Microseconds]]).
</emu-alg>
</emu-clause>
<emu-clause id="sec-get-temporal.duration.prototype.nanoseconds">
<h1>get Temporal.Duration.prototype.nanoseconds</h1>
<p>
`Temporal.Duration.prototype.nanoseconds` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
</p>
<emu-alg>
1. Let _duration_ be the *this* value.
1. Perform ? RequireInternalSlot(_duration_, [[InitializedTemporalDuration]]).
1. Return 𝔽(_duration_.[[Nanoseconds]]).
</emu-alg>
</emu-clause>
<emu-clause id="sec-get-temporal.duration.prototype.sign">
<h1>get Temporal.Duration.prototype.sign</h1>
<p>
`Temporal.Duration.prototype.sign` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
</p>
<emu-alg>
1. Let _duration_ be the *this* value.
1. Perform ? RequireInternalSlot(_duration_, [[InitializedTemporalDuration]]).
1. Return 𝔽(! DurationSign(_duration_.[[Years]], _duration_.[[Months]], _duration_.[[Weeks]], _duration_.[[Days]], _duration_.[[Hours]], _duration_.[[Minutes]], _duration_.[[Seconds]], _duration_.[[Milliseconds]], _duration_.[[Microseconds]], _duration_.[[Nanoseconds]])).
</emu-alg>
</emu-clause>
<emu-clause id="sec-get-temporal.duration.prototype.blank">
<h1>get Temporal.Duration.prototype.blank</h1>
<p>
`Temporal.Duration.prototype.blank` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
</p>
<emu-alg>
1. Let _duration_ be the *this* value.
1. Perform ? RequireInternalSlot(_duration_, [[InitializedTemporalDuration]]).
1. Let _sign_ be ! DurationSign(_duration_.[[Years]], _duration_.[[Months]], _duration_.[[Weeks]], _duration_.[[Days]], _duration_.[[Hours]], _duration_.[[Minutes]], _duration_.[[Seconds]], _duration_.[[Milliseconds]], _duration_.[[Microseconds]], _duration_.[[Nanoseconds]]).
1. If _sign_ = 0, return *true*.
1. Return *false*.
</emu-alg>
</emu-clause>
<emu-clause id="sec-temporal.duration.prototype.with">
<h1>Temporal.Duration.prototype.with ( _temporalDurationLike_ )</h1>
<p>
The `Temporal.Duration.prototype.with` method performs the following steps when called:
</p>
<emu-alg>
1. Let _duration_ be the *this* value.
1. Perform ? RequireInternalSlot(_duration_, [[InitializedTemporalDuration]]).
1. Let _temporalDurationLike_ be ? ToTemporalPartialDurationRecord(_temporalDurationLike_).
1. If _temporalDurationLike_.[[Years]] is not *undefined*, then
1. Let _years_ be _temporalDurationLike_.[[Years]].
1. Else,
1. Let _years_ be _duration_.[[Years]].
1. If _temporalDurationLike_.[[Months]] is not *undefined*, then
1. Let _months_ be _temporalDurationLike_.[[Months]].
1. Else,
1. Let _months_ be _duration_.[[Months]].
1. If _temporalDurationLike_.[[Weeks]] is not *undefined*, then
1. Let _weeks_ be _temporalDurationLike_.[[Weeks]].
1. Else,
1. Let _weeks_ be _duration_.[[Weeks]].
1. If _temporalDurationLike_.[[Days]] is not *undefined*, then
1. Let _days_ be _temporalDurationLike_.[[Days]].
1. Else,
1. Let _days_ be _duration_.[[Days]].
1. If _temporalDurationLike_.[[Hours]] is not *undefined*, then
1. Let _hours_ be _temporalDurationLike_.[[Hours]].
1. Else,
1. Let _hours_ be _duration_.[[Hours]].
1. If _temporalDurationLike_.[[Minutes]] is not *undefined*, then
1. Let _minutes_ be _temporalDurationLike_.[[Minutes]].
1. Else,
1. Let _minutes_ be _duration_.[[Minutes]].
1. If _temporalDurationLike_.[[Seconds]] is not *undefined*, then
1. Let _seconds_ be _temporalDurationLike_.[[Seconds]].
1. Else,
1. Let _seconds_ be _duration_.[[Seconds]].
1. If _temporalDurationLike_.[[Milliseconds]] is not *undefined*, then
1. Let _milliseconds_ be _temporalDurationLike_.[[Milliseconds]].
1. Else,
1. Let _milliseconds_ be _duration_.[[Milliseconds]].
1. If _temporalDurationLike_.[[Microseconds]] is not *undefined*, then
1. Let _microseconds_ be _temporalDurationLike_.[[Microseconds]].
1. Else,
1. Let _microseconds_ be _duration_.[[Microseconds]].
1. If _temporalDurationLike_.[[Nanoseconds]] is not *undefined*, then
1. Let _nanoseconds_ be _temporalDurationLike_.[[Nanoseconds]].
1. Else,
1. Let _nanoseconds_ be _duration_.[[Nanoseconds]].
1. Return ? CreateTemporalDuration(_years_, _months_, _weeks_, _days_, _hours_, _minutes_, _seconds_, _milliseconds_, _microseconds_, _nanoseconds_).
</emu-alg>
</emu-clause>
<emu-clause id="sec-temporal.duration.prototype.negated">
<h1>Temporal.Duration.prototype.negated ( )</h1>
<p>
The `Temporal.Duration.prototype.negated` method performs the following steps when called:
</p>
<emu-alg>
1. Let _duration_ be the *this* value.
1. Perform ? RequireInternalSlot(_duration_, [[InitializedTemporalDuration]]).
1. Return ! CreateNegatedTemporalDuration(_duration_).
</emu-alg>
</emu-clause>
<emu-clause id="sec-temporal.duration.prototype.abs">
<h1>Temporal.Duration.prototype.abs ( )</h1>
<p>
The `Temporal.Duration.prototype.abs` method performs the following steps when called:
</p>
<emu-alg>
1. Let _duration_ be the *this* value.
1. Perform ? RequireInternalSlot(_duration_, [[InitializedTemporalDuration]]).
1. Return ! CreateTemporalDuration(abs(_duration_.[[Years]]), abs(_duration_.[[Months]]), abs(_duration_.[[Weeks]]), abs(_duration_.[[Days]]), abs(_duration_.[[Hours]]), abs(_duration_.[[Minutes]]), abs(_duration_.[[Seconds]]), abs(_duration_.[[Milliseconds]]), abs(_duration_.[[Microseconds]]), abs(_duration_.[[Nanoseconds]])).
</emu-alg>
</emu-clause>
<emu-clause id="sec-temporal.duration.prototype.add">
<h1>Temporal.Duration.prototype.add ( _other_ [ , _options_ ] )</h1>
<p>
The `Temporal.Duration.prototype.add` method performs the following steps when called:
</p>
<emu-alg>
1. Let _duration_ be the *this* value.
1. Perform ? RequireInternalSlot(_duration_, [[InitializedTemporalDuration]]).
1. Return ? AddDurationToOrSubtractDurationFromDuration(~add~, _duration_, _other_, _options_).
</emu-alg>
</emu-clause>
<emu-clause id="sec-temporal.duration.prototype.subtract">
<h1>Temporal.Duration.prototype.subtract ( _other_ [ , _options_ ] )</h1>
<p>
The `Temporal.Duration.prototype.subtract` method performs the following steps when called:
</p>
<emu-alg>
1. Let _duration_ be the *this* value.
1. Perform ? RequireInternalSlot(_duration_, [[InitializedTemporalDuration]]).
1. Return ? AddDurationToOrSubtractDurationFromDuration(~subtract~, _duration_, _other_, _options_).
</emu-alg>
</emu-clause>
<emu-clause id="sec-temporal.duration.prototype.round">
<h1>Temporal.Duration.prototype.round ( _roundTo_ )</h1>
<p>
The `Temporal.Duration.prototype.round` method performs the following steps when called:
</p>
<emu-alg>
1. Let _duration_ be the *this* value.
1. Perform ? RequireInternalSlot(_duration_, [[InitializedTemporalDuration]]).
1. If _roundTo_ is *undefined*, then
1. Throw a *TypeError* exception.
1. If Type(_roundTo_) is String, then
1. Let _paramString_ be _roundTo_.
1. Set _roundTo_ to OrdinaryObjectCreate(*null*).
1. Perform ! CreateDataPropertyOrThrow(_roundTo_, *"smallestUnit"*, _paramString_).
1. Else,
1. Set _roundTo_ to ? GetOptionsObject(_roundTo_).
1. Let _smallestUnitPresent_ be *true*.
1. Let _largestUnitPresent_ be *true*.
1. NOTE: The following steps read options and perform independent validation in alphabetical order (ToRelativeTemporalObject reads *"relativeTo"*, ToTemporalRoundingIncrement reads *"roundingIncrement"* and ToTemporalRoundingMode reads *"roundingMode"*).
1. Let _largestUnit_ be ? GetTemporalUnit(_roundTo_, *"largestUnit"*, ~datetime~, *undefined*, « *"auto"* »).
1. Let _relativeToRecord_ be ? ToRelativeTemporalObject(_roundTo_).
1. Let _zonedRelativeTo_ be _relativeToRecord_.[[ZonedRelativeTo]].
1. Let _plainRelativeTo_ be _relativeToRecord_.[[PlainRelativeTo]].
1. Let _roundingIncrement_ be ? ToTemporalRoundingIncrement(_roundTo_).
1. Let _roundingMode_ be ? ToTemporalRoundingMode(_roundTo_, *"halfExpand"*).
1. Let _smallestUnit_ be ? GetTemporalUnit(_roundTo_, *"smallestUnit"*, ~datetime~, *undefined*).
1. If _smallestUnit_ is *undefined*, then
1. Set _smallestUnitPresent_ to *false*.
1. Set _smallestUnit_ to *"nanosecond"*.
1. Let _existingLargestUnit_ be ! DefaultTemporalLargestUnit(_duration_.[[Years]], _duration_.[[Months]], _duration_.[[Weeks]], _duration_.[[Days]], _duration_.[[Hours]], _duration_.[[Minutes]], _duration_.[[Seconds]], _duration_.[[Milliseconds]], _duration_.[[Microseconds]]).
1. Let _defaultLargestUnit_ be ! LargerOfTwoTemporalUnits(_existingLargestUnit_, _smallestUnit_).
1. If _largestUnit_ is *undefined*, then
1. Set _largestUnitPresent_ to *false*.
1. Set _largestUnit_ to _defaultLargestUnit_.
1. Else if _largestUnit_ is *"auto"*, then
1. Set _largestUnit_ to _defaultLargestUnit_.
1. If _smallestUnitPresent_ is *false* and _largestUnitPresent_ is *false*, then
1. Throw a *RangeError* exception.
1. If LargerOfTwoTemporalUnits(_largestUnit_, _smallestUnit_) is not _largestUnit_, throw a *RangeError* exception.
1. Let _maximum_ be ! MaximumTemporalDurationRoundingIncrement(_smallestUnit_).
1. If _maximum_ is not *undefined*, perform ? ValidateTemporalRoundingIncrement(_roundingIncrement_, _maximum_, *false*).
1. Let _hoursToDaysConversionMayOccur_ be *false*.
1. If _duration_.[[Days]] ≠ 0 and _zonedRelativeTo_ is not *undefined*, set _hoursToDaysConversionMayOccur_ to *true*.
1. Else if abs(_duration_.[[Hours]]) ≥ 24, set _hoursToDaysConversionMayOccur_ to *true*.
1. If _smallestUnit_ is *"nanosecond"* and _roundingIncrement_ = 1, let _roundingGranularityIsNoop_ be *true*; else let _roundingGranularityIsNoop_ be *false*.
1. If _duration_.[[Years]] = 0 and _duration_.[[Months]] = 0 and _duration_.[[Weeks]] = 0, let _calendarUnitsPresent_ be *false*; else let _calendarUnitsPresent_ be *true*.
1. If _roundingGranularityIsNoop_ is *true*, and _largestUnit_ is _existingLargestUnit_, and _calendarUnitsPresent_ is *false*, and _hoursToDaysConversionMayOccur_ is *false*, and abs(_duration_.[[Minutes]]) < 60, and abs(_duration_.[[Seconds]]) < 60, and abs(_duration_.[[Milliseconds]]) < 1000, and abs(_duration_.[[Microseconds]]) < 1000, and abs(_duration_.[[Nanoseconds]]) < 1000, then
1. NOTE: The above conditions mean that the operation will have no effect: the smallest unit and rounding increment will leave the total duration unchanged, and it can be determined without calling a calendar or time zone method that no balancing will take place.
1. Return ! CreateTemporalDuration(_duration_.[[Years]], _duration_.[[Months]], _duration_.[[Weeks]], _duration_.[[Days]], _duration_.[[Hours]], _duration_.[[Minutes]], _duration_.[[Seconds]], _duration_.[[Milliseconds]], _duration_.[[Microseconds]], _duration_.[[Nanoseconds]]).
1. Let _precalculatedPlainDateTime_ be *undefined*.
1. If _roundingGranularityIsNoop_ is *false*, or _largestUnit_ is *"year"*, or _largestUnit_ is *"month"*, or _largestUnit_ is *"week"*, or _largestUnit_ is *"day"*, or _calendarUnitsPresent_ is *true*, or _duration_.[[Days]] ≠ 0, let _plainDateTimeOrRelativeToWillBeUsed_ be *true*; else let _plainDateTimeOrRelativeToWillBeUsed_ be *false*.
1. If _zonedRelativeTo_ is not *undefined* and _plainDateTimeOrRelativeToWillBeUsed_ is *true*, then
1. NOTE: The above conditions mean that the corresponding `Temporal.PlainDateTime` or `Temporal.PlainDate` for _zonedRelativeTo_ will be used in one of the operations below.
1. Let _instant_ be ! CreateTemporalInstant(_zonedRelativeTo_.[[Nanoseconds]]).
1. Set _precalculatedPlainDateTime_ to ? GetPlainDateTimeFor(_zonedRelativeTo_.[[TimeZone]], _instant_, _zonedRelativeTo_.[[Calendar]]).
1. Set _plainRelativeTo_ to ! CreateTemporalDate(_precalculatedPlainDateTime_.[[ISOYear]], _precalculatedPlainDateTime_.[[ISOMonth]], _precalculatedPlainDateTime_.[[ISODay]], _zonedRelativeTo_.[[Calendar]]).
1. Let _unbalanceResult_ be ? UnbalanceDateDurationRelative(_duration_.[[Years]], _duration_.[[Months]], _duration_.[[Weeks]], _duration_.[[Days]], _largestUnit_, _plainRelativeTo_).
1. Let _roundRecord_ be ? RoundDuration(_unbalanceResult_.[[Years]], _unbalanceResult_.[[Months]], _unbalanceResult_.[[Weeks]], _unbalanceResult_.[[Days]], _duration_.[[Hours]], _duration_.[[Minutes]], _duration_.[[Seconds]], _duration_.[[Milliseconds]], _duration_.[[Microseconds]], _duration_.[[Nanoseconds]], _roundingIncrement_, _smallestUnit_, _roundingMode_, _plainRelativeTo_, _zonedRelativeTo_, _precalculatedPlainDateTime_).
1. Let _roundResult_ be _roundRecord_.[[DurationRecord]].
1. If _zonedRelativeTo_ is not *undefined*, then
1. Set _roundResult_ to ? AdjustRoundedDurationDays(_roundResult_.[[Years]], _roundResult_.[[Months]], _roundResult_.[[Weeks]], _roundResult_.[[Days]], _roundResult_.[[Hours]], _roundResult_.[[Minutes]], _roundResult_.[[Seconds]], _roundResult_.[[Milliseconds]], _roundResult_.[[Microseconds]], _roundResult_.[[Nanoseconds]], _roundingIncrement_, _smallestUnit_, _roundingMode_, _zonedRelativeTo_, _precalculatedPlainDateTime_).
1. Let _balanceResult_ be ? BalanceTimeDurationRelative(_roundResult_.[[Days]], _roundResult_.[[Hours]], _roundResult_.[[Minutes]], _roundResult_.[[Seconds]], _roundResult_.[[Milliseconds]], _roundResult_.[[Microseconds]], _roundResult_.[[Nanoseconds]], _largestUnit_, _zonedRelativeTo_, _precalculatedPlainDateTime_).
1. Else,
1. Let _balanceResult_ be ? BalanceTimeDuration(_roundResult_.[[Days]], _roundResult_.[[Hours]], _roundResult_.[[Minutes]], _roundResult_.[[Seconds]], _roundResult_.[[Milliseconds]], _roundResult_.[[Microseconds]], _roundResult_.[[Nanoseconds]], _largestUnit_).
1. Let _result_ be ? BalanceDateDurationRelative(_roundResult_.[[Years]], _roundResult_.[[Months]], _roundResult_.[[Weeks]], _balanceResult_.[[Days]], _largestUnit_, _plainRelativeTo_).
1. Return ! CreateTemporalDuration(_result_.[[Years]], _result_.[[Months]], _result_.[[Weeks]], _result_.[[Days]], _balanceResult_.[[Hours]], _balanceResult_.[[Minutes]], _balanceResult_.[[Seconds]], _balanceResult_.[[Milliseconds]], _balanceResult_.[[Microseconds]], _balanceResult_.[[Nanoseconds]]).
</emu-alg>
</emu-clause>
<emu-clause id="sec-temporal.duration.prototype.total">
<h1>Temporal.Duration.prototype.total ( _totalOf_ )</h1>
<p>
The `Temporal.Duration.prototype.total` method performs the following steps when called:
</p>
<emu-alg>
1. Let _duration_ be the *this* value.
1. Perform ? RequireInternalSlot(_duration_, [[InitializedTemporalDuration]]).
1. If _totalOf_ is *undefined*, throw a *TypeError* exception.
1. If Type(_totalOf_) is String, then
1. Let _paramString_ be _totalOf_.
1. Set _totalOf_ to OrdinaryObjectCreate(*null*).
1. Perform ! CreateDataPropertyOrThrow(_totalOf_, *"unit"*, _paramString_).
1. Else,
1. Set _totalOf_ to ? GetOptionsObject(_totalOf_).
1. NOTE: The following steps read options and perform independent validation in alphabetical order (ToRelativeTemporalObject reads *"relativeTo"*).
1. Let _relativeToRecord_ be ? ToRelativeTemporalObject(_totalOf_).
1. Let _zonedRelativeTo_ be _relativeToRecord_.[[ZonedRelativeTo]].
1. Let _plainRelativeTo_ be _relativeToRecord_.[[PlainRelativeTo]].
1. Let _unit_ be ? GetTemporalUnit(_totalOf_, *"unit"*, ~datetime~, ~required~).
1. Let _precalculatedPlainDateTime_ be *undefined*.
1. If _unit_ is *"year"*, or _unit_ is *"month"*, or _unit_ is *"week"*, or _unit_ is *"day"*, or _duration_.[[Years]] ≠ 0, or _duration_.[[Months]] ≠ 0, or _duration_.[[Weeks]] ≠ 0, or _duration_.[[Days]] ≠ 0, let _plainDateTimeOrRelativeToWillBeUsed_ be *true*; else let _plainDateTimeOrRelativeToWillBeUsed_ be *false*.
1. If _zonedRelativeTo_ is not *undefined* and _plainDateTimeOrRelativeToWillBeUsed_ is *true*, then
1. NOTE: The above conditions mean that the corresponding `Temporal.PlainDateTime` or `Temporal.PlainDate` for _zonedRelativeTo_ will be used in one of the operations below.
1. Let _instant_ be ! CreateTemporalInstant(_zonedRelativeTo_.[[Nanoseconds]]).
1. Set _precalculatedPlainDateTime_ to ? GetPlainDateTimeFor(_zonedRelativeTo_.[[TimeZone]], _instant_, _zonedRelativeTo_.[[Calendar]]).
1. Set _plainRelativeTo_ to ! CreateTemporalDate(_precalculatedPlainDateTime_.[[ISOYear]], _precalculatedPlainDateTime_.[[ISOMonth]], _precalculatedPlainDateTime_.[[ISODay]], _zonedRelativeTo_.[[Calendar]]).
1. Let _unbalanceResult_ be ? UnbalanceDateDurationRelative(_duration_.[[Years]], _duration_.[[Months]], _duration_.[[Weeks]], _duration_.[[Days]], _unit_, _plainRelativeTo_).
1. If _zonedRelativeTo_ is not *undefined*, then
1. Let _intermediate_ be ? MoveRelativeZonedDateTime(_zonedRelativeTo_, _unbalanceResult_.[[Years]], _unbalanceResult_.[[Months]], _unbalanceResult_.[[Weeks]], 0, _precalculatedPlainDateTime_).
1. Let _balanceResult_ be ? BalancePossiblyInfiniteTimeDurationRelative(_unbalanceResult_.[[Days]], _duration_.[[Hours]], _duration_.[[Minutes]], _duration_.[[Seconds]], _duration_.[[Milliseconds]], _duration_.[[Microseconds]], _duration_.[[Nanoseconds]], _unit_, _intermediate_).
1. Else,
1. Let _balanceResult_ be BalancePossiblyInfiniteTimeDuration(_unbalanceResult_.[[Days]], _duration_.[[Hours]], _duration_.[[Minutes]], _duration_.[[Seconds]], _duration_.[[Milliseconds]], _duration_.[[Microseconds]], _duration_.[[Nanoseconds]], _unit_).
1. If _balanceResult_ is ~positive overflow~, return *+∞*<sub>𝔽</sub>.
1. If _balanceResult_ is ~negative overflow~, return *-∞*<sub>𝔽</sub>.
1. Assert: _balanceResult_ is a Time Duration Record.
1. Let _roundRecord_ be ? RoundDuration(_unbalanceResult_.[[Years]], _unbalanceResult_.[[Months]], _unbalanceResult_.[[Weeks]], _balanceResult_.[[Days]], _balanceResult_.[[Hours]], _balanceResult_.[[Minutes]], _balanceResult_.[[Seconds]], _balanceResult_.[[Milliseconds]], _balanceResult_.[[Microseconds]], _balanceResult_.[[Nanoseconds]], 1, _unit_, *"trunc"*, _plainRelativeTo_, _zonedRelativeTo_, _precalculatedPlainDateTime_).
1. Return 𝔽(_roundRecord_.[[Total]]).
</emu-alg>
</emu-clause>
<emu-clause id="sec-temporal.duration.prototype.tostring">
<h1>Temporal.Duration.prototype.toString ( [ _options_ ] )</h1>
<p>
The `Temporal.Duration.prototype.toString` method performs the following steps when called:
</p>
<emu-alg>
1. Let _duration_ be the *this* value.
1. Perform ? RequireInternalSlot(_duration_, [[InitializedTemporalDuration]]).
1. Set _options_ to ? GetOptionsObject(_options_).
1. NOTE: The following steps read options and perform independent validation in alphabetical order (ToFractionalSecondDigits reads *"fractionalSecondDigits"* and ToTemporalRoundingMode reads *"roundingMode"*).
1. Let _digits_ be ? ToFractionalSecondDigits(_options_).
1. Let _roundingMode_ be ? ToTemporalRoundingMode(_options_, *"trunc"*).
1. Let _smallestUnit_ be ? GetTemporalUnit(_options_, *"smallestUnit"*, ~time~, *undefined*).
1. If _smallestUnit_ is *"hour"* or *"minute"*, throw a *RangeError* exception.
1. Let _precision_ be ToSecondsStringPrecisionRecord(_smallestUnit_, _digits_).
1. Let _roundRecord_ be ? RoundDuration(0, 0, 0, 0, 0, 0, _duration_.[[Seconds]], _duration_.[[Milliseconds]], _duration_.[[Microseconds]], _duration_.[[Nanoseconds]], _precision_.[[Increment]], _precision_.[[Unit]], _roundingMode_).
1. Let _result_ be _roundRecord_.[[DurationRecord]].
1. Return ! TemporalDurationToString(_duration_.[[Years]], _duration_.[[Months]], _duration_.[[Weeks]], _duration_.[[Days]], _duration_.[[Hours]], _duration_.[[Minutes]], _result_.[[Seconds]], _result_.[[Milliseconds]], _result_.[[Microseconds]], _result_.[[Nanoseconds]], _precision_.[[Precision]]).
</emu-alg>
</emu-clause>
<emu-clause id="sec-temporal.duration.prototype.tojson">
<h1>Temporal.Duration.prototype.toJSON ( )</h1>
<p>
The `Temporal.Duration.prototype.toJSON` method performs the following steps when called:
</p>
<emu-alg>
1. Let _duration_ be the *this* value.
1. Perform ? RequireInternalSlot(_duration_, [[InitializedTemporalDuration]]).
1. Return ! TemporalDurationToString(_duration_.[[Years]], _duration_.[[Months]], _duration_.[[Weeks]], _duration_.[[Days]], _duration_.[[Hours]], _duration_.[[Minutes]], _duration_.[[Seconds]], _duration_.[[Milliseconds]], _duration_.[[Microseconds]], _duration_.[[Nanoseconds]], *"auto"*).
</emu-alg>
</emu-clause>
<emu-clause id="sec-temporal.duration.prototype.tolocalestring">
<h1>Temporal.Duration.prototype.toLocaleString ( [ _locales_ [ , _options_ ] ] )</h1>
<p>
An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement the `Temporal.Duration.prototype.toLocaleString` method as specified in the ECMA-402 specification.
If an ECMAScript implementation does not include the ECMA-402 API the following specification of the `Temporal.Duration.prototype.toLocaleString` method is used.
</p>
<p>
The `Temporal.Duration.prototype.toLocaleString` method performs the following steps when called:
</p>
<emu-alg>
1. Let _duration_ be the *this* value.
1. Perform ? RequireInternalSlot(_duration_, [[InitializedTemporalDuration]]).
1. Return ! TemporalDurationToString(_duration_.[[Years]], _duration_.[[Months]], _duration_.[[Weeks]], _duration_.[[Days]], _duration_.[[Hours]], _duration_.[[Minutes]], _duration_.[[Seconds]], _duration_.[[Milliseconds]], _duration_.[[Microseconds]], _duration_.[[Nanoseconds]], *"auto"*).
</emu-alg>
</emu-clause>
<emu-clause id="sec-temporal.duration.prototype.valueof">
<h1>Temporal.Duration.prototype.valueOf ( )</h1>
<p>
The `Temporal.Duration.prototype.valueOf` method performs the following steps when called:
</p>
<emu-alg>
1. Throw a *TypeError* exception.
</emu-alg>
</emu-clause>
</emu-clause>
<emu-clause id="sec-properties-of-temporal-duration-instances">
<h1>Properties of Temporal.Duration Instances</h1>
<p>
Temporal.Duration instances are ordinary objects that inherit properties from the %Temporal.Duration.prototype% intrinsic object.
Temporal.Duration instances are initially created with the internal slots described in <emu-xref href="#table-internal-slots-of-temporalduration-instances"></emu-xref>.
</p>
<p>
A <dfn variants="float64-representable integers">float64-representable integer</dfn> is an integer that is exactly representable as a Number value.
That is, for a float64-representable integer _x_, it must hold that ℝ(𝔽(_x_)) = _x_.
</p>
<emu-note>
The use of float64-representable integers here is intended so that implementations can store and do arithmetic on Duration fields using 64-bit floating-point values.
</emu-note>
<emu-table id="table-internal-slots-of-temporalduration-instances" caption="Internal Slots of Temporal.Duration Instances">
<table>
<tbody>
<tr>
<th>
Internal Slot
</th>
<th>
Description
</th>
</tr>
<tr>
<td>
[[InitializedTemporalDuration]]
</td>
<td>
The only specified use of this slot is for distinguishing Temporal.Duration instances from other objects.
</td>
</tr>
<tr>
<td>
[[Years]]
</td>
<td>
A float64-representable integer representing the number of years in the duration.
</td>
</tr>
<tr>
<td>
[[Months]]
</td>
<td>
A float64-representable integer representing the number of months in the duration.
</td>
</tr>
<tr>
<td>
[[Weeks]]
</td>
<td>
A float64-representable integer representing the number of weeks in the duration.
</td>
</tr>
<tr>
<td>
[[Days]]
</td>
<td>
A float64-representable integer representing the number of days in the duration.
</td>
</tr>
<tr>
<td>
[[Hours]]
</td>
<td>
A float64-representable integer representing the number of hours in the duration.
</td>
</tr>
<tr>
<td>
[[Minutes]]
</td>
<td>
A float64-representable integer representing the number of minutes in the duration.
</td>
</tr>
<tr>
<td>
[[Seconds]]
</td>
<td>
A float64-representable integer representing the number of seconds in the duration.
</td>
</tr>
<tr>
<td>
[[Milliseconds]]
</td>
<td>
A float64-representable integer representing the number of milliseconds in the duration.
</td>
</tr>
<tr>
<td>
[[Microseconds]]
</td>
<td>
A float64-representable integer representing the number of microseconds in the duration.
</td>
</tr>
<tr>
<td>
[[Nanoseconds]]
</td>
<td>
A float64-representable integer representing the number of nanoseconds in the duration.
</td>
</tr>
</tbody>
</table>
</emu-table>
</emu-clause>
<emu-clause id="sec-temporal-duration-abstract-ops">
<h1>Abstract Operations</h1>
<emu-clause id="sec-temporal-duration-records">
<h1>Duration Records</h1>
<p>
A <dfn variants="Duration Records">Duration Record</dfn> is a Record value used to represent a Temporal.Duration object.
Duration Records are produced by the abstract operation CreateDurationRecord, among others.
</p>
<p>
Duration Records have the fields listed in <emu-xref href="#table-temporal-duration-record-fields"></emu-xref>.
</p>
<emu-table id="table-temporal-duration-record-fields" caption="Duration Record Fields">
<table class="real-table">
<tr>
<th>Field Name</th>
<th>Property Name</th>
<th>Value</th>
<th>Meaning</th>
</tr>
<tr>
<td>[[Years]]</td>
<td>*"years"*</td>
<td>a float64-representable integer</td>
<td>
The number of years in the duration.
</td>
</tr>
<tr>
<td>[[Months]]</td>
<td>*"months"*</td>
<td>a float64-representable integer</td>
<td>
The number of months in the duration.
</td>
</tr>
<tr>
<td>[[Weeks]]</td>
<td>*"weeks"*</td>
<td>a float64-representable integer</td>
<td>
The number of weeks in the duration.
</td>
</tr>
<tr>
<td>[[Days]]</td>
<td>*"days"*</td>
<td>a float64-representable integer</td>
<td>
The number of days in the duration.
</td>
</tr>
<tr>
<td>[[Hours]]</td>
<td>*"hours"*</td>
<td>a float64-representable integer</td>
<td>
The number of hours in the duration.
</td>
</tr>
<tr>
<td>[[Minutes]]</td>
<td>*"minutes"*</td>
<td>a float64-representable integer</td>
<td>
The number of minutes in the duration.
</td>
</tr>
<tr>
<td>[[Seconds]]</td>
<td>*"seconds"*</td>
<td>a float64-representable integer</td>
<td>
The number of seconds in the duration.
</td>
</tr>
<tr>
<td>[[Milliseconds]]</td>
<td>*"milliseconds"*</td>
<td>a float64-representable integer</td>
<td>
The number of milliseconds in the duration.
</td>
</tr>
<tr>
<td>[[Microseconds]]</td>
<td>*"microseconds"*</td>
<td>a float64-representable integer</td>
<td>
The number of microseconds in the duration.
</td>
</tr>
<tr>
<td>[[Nanoseconds]]</td>
<td>*"nanoseconds"*</td>
<td>a float64-representable integer</td>
<td>
The number of nanoseconds in the duration.
</td>
</tr>
</table>
</emu-table>
</emu-clause>
<emu-clause id="sec-temporal-date-duration-records">
<h1>Date Duration Records</h1>
<p>
A <dfn variants="Date Duration Records">Date Duration Record</dfn> is a Record value used to represent the portion of a Temporal.Duration object that deals with calendar date units.
Date Duration Records are produced by the abstract operation CreateDateDurationRecord, among others.
</p>
<p>
Of the fields listed in <emu-xref href="#table-temporal-duration-record-fields"></emu-xref>, Date Duration Records have [[Years]], [[Months]], [[Weeks]], and [[Days]].
</p>
</emu-clause>
<emu-clause id="sec-temporal-time-duration-records">
<h1>Time Duration Records</h1>
<p>
A <dfn variants="Time Duration Records">Time Duration Record</dfn> is a Record value used to represent the portion of a Temporal.Duration object that deals with exact time units.
Time Duration Records are produced by the abstract operation CreateTimeDurationRecord, among others.
</p>
<p>
Of the fields listed in <emu-xref href="#table-temporal-duration-record-fields"></emu-xref>, Time Duration Records have [[Days]], [[Hours]], [[Minutes]], [[Seconds]], [[Milliseconds]], [[Microseconds]], and [[Nanoseconds]].
</p>
</emu-clause>
<emu-clause id="sec-temporal-partial-duration-records">
<h1>Partial Duration Records</h1>
<p>
A <dfn variants="partial Duration Records">partial Duration Record</dfn> is a Record value used to represent a portion of a Temporal.Duration object, in which it is not required that all the fields be specified.
</p>
<p>
Partial Duration Records have the same fields listed in <emu-xref href="#table-temporal-duration-record-fields"></emu-xref>.
Unlike Duration Records, each field of a partial Duration Record may also have the value *undefined* as long as there is at least one field that is not *undefined*.
</p>
</emu-clause>
<emu-clause id="sec-temporal-createdurationrecord" type="abstract operation">
<h1>
CreateDurationRecord (
_years_: an integer,
_months_: an integer,
_weeks_: an integer,
_days_: an integer,
_hours_: an integer,
_minutes_: an integer,
_seconds_: an integer,
_milliseconds_: an integer,
_microseconds_: an integer,
_nanoseconds_: an integer,
): either a normal completion containing a Duration Record, or a throw completion
</h1>
<dl class="header">
<dt>description</dt>
<dd></dd>
</dl>
<emu-alg>
1. If ! IsValidDuration(_years_, _months_, _weeks_, _days_, _hours_, _minutes_, _seconds_, _milliseconds_, _microseconds_, _nanoseconds_) is *false*, throw a *RangeError* exception.
1. Return the Record {
[[Years]]: ℝ(𝔽(_years_)),
[[Months]]: ℝ(𝔽(_months_)),
[[Weeks]]: ℝ(𝔽(_weeks_)),
[[Days]]: ℝ(𝔽(_days_)),
[[Hours]]: ℝ(𝔽(_hours_)),
[[Minutes]]: ℝ(𝔽(_minutes_)),
[[Seconds]]: ℝ(𝔽(_seconds_)),
[[Milliseconds]]: ℝ(𝔽(_milliseconds_)),
[[Microseconds]]: ℝ(𝔽(_microseconds_)),
[[Nanoseconds]]: ℝ(𝔽(_nanoseconds_))
}.
</emu-alg>
</emu-clause>
<emu-clause id="sec-temporal-createdatedurationrecord" type="abstract operation">
<h1>
CreateDateDurationRecord (
_years_: an integer,
_months_: an integer,
_weeks_: an integer,
_days_: an integer,
)
</h1>
<dl class="header">
<dt>description</dt>
<dd>It returns a Date Duration Record.</dd>
</dl>
<emu-alg>
1. If ! IsValidDuration(_years_, _months_, _weeks_, _days_, 0, 0, 0, 0, 0, 0) is *false*, throw a *RangeError* exception.
1. Return the Record {
[[Years]]: ℝ(𝔽(_years_)),
[[Months]]: ℝ(𝔽(_months_)),
[[Weeks]]: ℝ(𝔽(_weeks_)),
[[Days]]: ℝ(𝔽(_days_))
}.
</emu-alg>
</emu-clause>
<emu-clause id="sec-temporal-createtimedurationrecord" type="abstract operation">
<h1>
CreateTimeDurationRecord (
_days_: an integer,
_hours_: an integer,
_minutes_: an integer,
_seconds_: an integer,
_milliseconds_: an integer,
_microseconds_: an integer,
_nanoseconds_: an integer,
)
</h1>
<dl class="header">
<dt>description</dt>
<dd>It returns a Time Duration Record.</dd>
</dl>
<emu-alg>
1. Assert: ! IsValidDuration(0, 0, 0, _days_, _hours_, _minutes_, _seconds_, _milliseconds_, _microseconds_, _nanoseconds_) is *true*.
1. Return the Record {
[[Days]]: ℝ(𝔽(_days_)),
[[Hours]]: ℝ(𝔽(_hours_)),
[[Minutes]]: ℝ(𝔽(_minutes_)),
[[Seconds]]: ℝ(𝔽(_seconds_)),
[[Milliseconds]]: ℝ(𝔽(_milliseconds_)),
[[Microseconds]]: ℝ(𝔽(_microseconds_)),
[[Nanoseconds]]: ℝ(𝔽(_nanoseconds_))
}.
</emu-alg>
</emu-clause>
<emu-clause id="sec-temporal-totemporalduration" type="abstract operation">
<h1>
ToTemporalDuration (
_item_: an ECMAScript language value,
): either a normal completion containing a Temporal.Duration, or a throw completion
</h1>
<dl class="header">
<dt>description</dt>
<dd>It returns its argument _item_ if it is already a Temporal.Duration instance, converts _item_ to a new Temporal.Duration instance if possible and returns that, and throws otherwise.</dd>
</dl>
<emu-alg>
1. If Type(_item_) is Object and _item_ has an [[InitializedTemporalDuration]] internal slot, then
1. Return _item_.
1. Let _result_ be ? ToTemporalDurationRecord(_item_).
1. Return ! CreateTemporalDuration(_result_.[[Years]], _result_.[[Months]], _result_.[[Weeks]], _result_.[[Days]], _result_.[[Hours]], _result_.[[Minutes]], _result_.[[Seconds]], _result_.[[Milliseconds]], _result_.[[Microseconds]], _result_.[[Nanoseconds]]).
</emu-alg>
</emu-clause>
<emu-clause id="sec-temporal-totemporaldurationrecord" type="abstract operation">
<h1>
ToTemporalDurationRecord (
_temporalDurationLike_: an ECMAScript language value,
): either a normal completion containing a Duration Record, or an abrupt completion
</h1>
<dl class="header">
<dt>description</dt>
<dd>The returned Record has its fields set according to the properties of _temporalDurationLike_, with absent or undefined properties corresponding to fields containing 0.</dd>
</dl>
<emu-alg>
1. If Type(_temporalDurationLike_) is not Object, then
1. If _temporalDurationLike_ is not a String, throw a *TypeError* exception.
1. Return ? ParseTemporalDurationString(_temporalDurationLike_).
1. If _temporalDurationLike_ has an [[InitializedTemporalDuration]] internal slot, then
1. Return ! CreateDurationRecord(_temporalDurationLike_.[[Years]], _temporalDurationLike_.[[Months]], _temporalDurationLike_.[[Weeks]], _temporalDurationLike_.[[Days]], _temporalDurationLike_.[[Hours]], _temporalDurationLike_.[[Minutes]], _temporalDurationLike_.[[Seconds]], _temporalDurationLike_.[[Milliseconds]], _temporalDurationLike_.[[Microseconds]], _temporalDurationLike_.[[Nanoseconds]]).
1. Let _result_ be a new Duration Record with each field set to 0.
1. Let _partial_ be ? ToTemporalPartialDurationRecord(_temporalDurationLike_).
1. If _partial_.[[Years]] is not *undefined*, set _result_.[[Years]] to _partial_.[[Years]].
1. If _partial_.[[Months]] is not *undefined*, set _result_.[[Months]] to _partial_.[[Months]].
1. If _partial_.[[Weeks]] is not *undefined*, set _result_.[[Weeks]] to _partial_.[[Weeks]].
1. If _partial_.[[Days]] is not *undefined*, set _result_.[[Days]] to _partial_.[[Days]].
1. If _partial_.[[Hours]] is not *undefined*, set _result_.[[Hours]] to _partial_.[[Hours]].
1. If _partial_.[[Minutes]] is not *undefined*, set _result_.[[Minutes]] to _partial_.[[Minutes]].
1. If _partial_.[[Seconds]] is not *undefined*, set _result_.[[Seconds]] to _partial_.[[Seconds]].
1. If _partial_.[[Milliseconds]] is not *undefined*, set _result_.[[Milliseconds]] to _partial_.[[Milliseconds]].
1. If _partial_.[[Microseconds]] is not *undefined*, set _result_.[[Microseconds]] to _partial_.[[Microseconds]].
1. If _partial_.[[Nanoseconds]] is not *undefined*, set _result_.[[Nanoseconds]] to _partial_.[[Nanoseconds]].
1. If ! IsValidDuration(_result_.[[Years]], _result_.[[Months]], _result_.[[Weeks]], _result_.[[Days]], _result_.[[Hours]], _result_.[[Minutes]], _result_.[[Seconds]], _result_.[[Milliseconds]], _result_.[[Microseconds]], _result_.[[Nanoseconds]]) is *false*, then
1. Throw a *RangeError* exception.
1. Return _result_.
</emu-alg>
</emu-clause>
<emu-clause id="sec-temporal-durationsign" type="abstract operation">
<h1>
DurationSign (
_years_: an integer,
_months_: an integer,
_weeks_: an integer,
_days_: an integer,
_hours_: an integer,
_minutes_: an integer,
_seconds_: an integer,
_milliseconds_: an integer,
_microseconds_: an integer,
_nanoseconds_: an integer,
)
</h1>
<dl class="header">
<dt>description</dt>
<dd>It returns 1 if the most significant non-zero element in its arguments is positive, and -1 if the most significant non-zero element is negative. If all of its arguments are zero, it returns 0.</dd>
</dl>
<emu-alg>
1. For each value _v_ of « _years_, _months_, _weeks_, _days_, _hours_, _minutes_, _seconds_, _milliseconds_, _microseconds_, _nanoseconds_ », do
1. If _v_ < 0, return -1.