[#BloombergLP-bsls-TimeInterval-2constructor-01]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bsls.adoc[bsls]::xref:BloombergLP/bsls/TimeInterval.adoc[TimeInterval]::TimeInterval
:relfileprefix: ../../../
:mrdocs:

Constructors

== Synopses

Declared in `&lt;bsls&lowbar;timeinterval&period;h&gt;`

Create a time interval having the value of 0 seconds and 0 nanoseconds&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
constexpr
xref:BloombergLP/bsls/TimeInterval/2constructor-06.adoc[TimeInterval]();
----

[.small]#xref:BloombergLP/bsls/TimeInterval/2constructor-06.adoc[_» more&period;&period;&period;_]#

Create a time interval having the value represented by the specified real number of `seconds`&period; The fractional part of `seconds`, if any, is rounded to the nearest whole number of nanoseconds&period; The behavior is undefined unless the total number of seconds in the resulting time interval can be represented with a 64&hyphen;bit signed integer&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
explicit
xref:BloombergLP/bsls/TimeInterval/2constructor-009.adoc[TimeInterval](double seconds);
----

[.small]#xref:BloombergLP/bsls/TimeInterval/2constructor-009.adoc[_» more&period;&period;&period;_]#

Create a time interval having the value given by the sum of the specified integral number of `seconds` and `nanoseconds`&period; The behavior is undefined unless the total number of seconds in the resulting time interval can be represented with a 64&hyphen;bit signed integer (see `isValid`)&period; Note that there is no restriction on the sign or magnitude of either argument except that they must not violate the method&apos;s preconditions&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
constexpr
xref:BloombergLP/bsls/TimeInterval/2constructor-000.adoc[TimeInterval](
    xref:BloombergLP/bsls/Types/Int64.adoc[bsls::Types::Int64] seconds,
    int nanoseconds);
----

[.small]#xref:BloombergLP/bsls/TimeInterval/2constructor-000.adoc[_» more&period;&period;&period;_]#

Create a time interval having the value represented by the specified `duration` when the conversion requires an explicit constructor&period; See the implicit overload for additional details on behavior and preconditions&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class REP&lowbar;TYPE,
    class PERIOD&lowbar;TYPE&gt;
constexpr
explicit
xref:BloombergLP/bsls/TimeInterval/2constructor-07.adoc[TimeInterval](
    std::chrono::duration&lt;REP&lowbar;TYPE, PERIOD&lowbar;TYPE&gt; const& duration,
    int* = 0)
requires TimeInterval&lowbar;DurationTraits&lt;
                                   REP&lowbar;TYPE,
                                   PERIOD&lowbar;TYPE&gt;&colon;&colon;k&lowbar;EXPLICIT&lowbar;CONVERSION&lowbar;ENABLED;
----

[.small]#xref:BloombergLP/bsls/TimeInterval/2constructor-07.adoc[_» more&period;&period;&period;_]#

Create a time interval having the value represented by the specified `duration`&period; Only integer representations of `duration` are supported (i&period;e&period; `REP&lowbar;TYPE` is integer)&period; If the `duration` can be represented _exactly_ by an integer nanoseconds this constructor will be implicit&period; Otherwise, the constructor will be explicit&period; The behavior is undefined unless the `duration` can be converted to a valid `TimeInterval` object, whose `seconds` field may have any 64&hyphen;bit signed integer value and `nanoseconds` field limited to the range `&lsqb; &hyphen;999,999,999&period;&period;999,999,999 &rsqb;`&period; Note that the current implementation of the lossy conversions (e&period;g&period;, fractions of a nanosecond) truncates the values towards zero, however this behavior may change without notice in the future, so _do not_ rely on this&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class REP&lowbar;TYPE,
    class PERIOD&lowbar;TYPE&gt;
constexpr
xref:BloombergLP/bsls/TimeInterval/2constructor-002.adoc[TimeInterval](
    std::chrono::duration&lt;REP&lowbar;TYPE, PERIOD&lowbar;TYPE&gt; const& duration,
    int* = 0)
requires TimeInterval&lowbar;DurationTraits&lt;
                                   REP&lowbar;TYPE,
                                   PERIOD&lowbar;TYPE&gt;&colon;&colon;k&lowbar;IMPLICIT&lowbar;CONVERSION&lowbar;ENABLED;
----

[.small]#xref:BloombergLP/bsls/TimeInterval/2constructor-002.adoc[_» more&period;&period;&period;_]#


[.small]#Created with https://www.mrdocs.com[MrDocs]#
