[#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 `<bsls_timeinterval.h>` Create a time interval having the value of 0 seconds and 0 nanoseconds. [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..._]# Create a time interval having the value represented by the specified real number of `seconds`. The fractional part of `seconds`, if any, is rounded to the nearest whole number of nanoseconds. The behavior is undefined unless the total number of seconds in the resulting time interval can be represented with a 64‐bit signed integer. [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..._]# Create a time interval having the value given by the sum of the specified integral number of `seconds` and `nanoseconds`. The behavior is undefined unless the total number of seconds in the resulting time interval can be represented with a 64‐bit signed integer (see `isValid`). Note that there is no restriction on the sign or magnitude of either argument except that they must not violate the method's preconditions. [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..._]# Create a time interval having the value represented by the specified `duration` when the conversion requires an explicit constructor. See the implicit overload for additional details on behavior and preconditions. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class REP_TYPE, class PERIOD_TYPE> constexpr explicit xref:BloombergLP/bsls/TimeInterval/2constructor-07.adoc[TimeInterval]( std::chrono::duration<REP_TYPE, PERIOD_TYPE> const& duration, int* = 0) requires TimeInterval_DurationTraits< REP_TYPE, PERIOD_TYPE>::k_EXPLICIT_CONVERSION_ENABLED; ---- [.small]#xref:BloombergLP/bsls/TimeInterval/2constructor-07.adoc[_» more..._]# Create a time interval having the value represented by the specified `duration`. Only integer representations of `duration` are supported (i.e. `REP_TYPE` is integer). If the `duration` can be represented _exactly_ by an integer nanoseconds this constructor will be implicit. Otherwise, the constructor will be explicit. The behavior is undefined unless the `duration` can be converted to a valid `TimeInterval` object, whose `seconds` field may have any 64‐bit signed integer value and `nanoseconds` field limited to the range `[ ‐999,999,999..999,999,999 ]`. Note that the current implementation of the lossy conversions (e.g., 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. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class REP_TYPE, class PERIOD_TYPE> constexpr xref:BloombergLP/bsls/TimeInterval/2constructor-002.adoc[TimeInterval]( std::chrono::duration<REP_TYPE, PERIOD_TYPE> const& duration, int* = 0) requires TimeInterval_DurationTraits< REP_TYPE, PERIOD_TYPE>::k_IMPLICIT_CONVERSION_ENABLED; ---- [.small]#xref:BloombergLP/bsls/TimeInterval/2constructor-002.adoc[_» more..._]# [.small]#Created with https://www.mrdocs.com[MrDocs]#