xtd 0.2.0
Loading...
Searching...
No Matches

◆ from_milliseconds() [1/2]

static time_span xtd::time_span::from_milliseconds ( double  value)
static

Returns a xtd::time_span that represents a specified number of milliseconds.

Parameters
valueA number of milliseconds.
Returns
An object that represents value.
Exceptions
xtd::overflow_exceptionvalue is less than xtd::time_span::min_value or greater than xtd::time_span::max_value.
-or-
value is xtd::double_object::positive_infinity.
-or-
value is xtd::double_object::negative_infinity.
xtd::argument_exceptionvalue is equal to xtd::double_object::NaN.
Remarks
The value parameter is converted to ticks, and that number of ticks is used to initialize the new xtd::time_span. Therefore, value will only be considered accurate to the nearest millisecond. Note that, because of the loss of precision of the Double data type, this conversion can generate an xtd::overflow_exception for values that are near to but still in the range of either xtd::time_span::min_value or xtd::time_span::max_value. For example, this causes an xtd::overflow_exception in the following attempt to instantiate a xtd::time_span object.
// The following throws an overflow_exception at runtime
auto max_span = time_span::from_milliseconds(time_span::max_value::total_milliseconds);
static time_span from_milliseconds(double value)
Returns a xtd::time_span that represents a specified number of milliseconds.