Struct TimeValue
- Namespace
- xFunc.Maths.Expressions.Units.TimeUnits
- Assembly
- xFunc.Maths.dll
Represents a number with unit.
public readonly struct TimeValue : IEquatable<TimeValue>, IComparable<TimeValue>, IComparable
- Implements
- Inherited Members
Constructors
TimeValue(NumberValue, TimeUnit)
Initializes a new instance of the TimeValue struct.
public TimeValue(NumberValue value, TimeUnit unit)
Parameters
valueNumberValueThe value.
unitTimeUnitThe unit of number.
Properties
Sign
Gets an integer that indicates the sign of a double-precision floating-point number.
public double Sign { get; }
Property Value
Unit
Gets a unit.
public TimeUnit Unit { get; }
Property Value
Value
Gets a value.
public NumberValue Value { get; }
Property Value
Methods
Abs(TimeValue)
Returns the absolute value of a specified value.
public static TimeValue Abs(TimeValue value)
Parameters
valueTimeValueThe value.
Returns
- TimeValue
The power value,
x, that such that 0 ≤x≤MaxValue.
AsExpression()
public Time AsExpression()
Returns
- Time
The length number.
Ceiling(TimeValue)
Returns the smallest integral value that is greater than or equal to the specified value.
public static TimeValue Ceiling(TimeValue value)
Parameters
valueTimeValueThe value.
Returns
- TimeValue
The smallest integral value.
CompareTo(object?)
Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
public int CompareTo(object? obj)
Parameters
objobjectAn object to compare with this instance.
Returns
- int
A value that indicates the relative order of the objects being compared. The return value has these meanings:
Value Meaning Less than zero This instance precedes objin the sort order.Zero This instance occurs in the same position in the sort order as obj.Greater than zero This instance follows objin the sort order.
Exceptions
- ArgumentException
objis not the same type as this instance.
CompareTo(TimeValue)
Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
public int CompareTo(TimeValue other)
Parameters
otherTimeValueAn object to compare with this instance.
Returns
- int
A value that indicates the relative order of the objects being compared. The return value has these meanings:
Value Meaning Less than zero This instance precedes otherin the sort order.Zero This instance occurs in the same position in the sort order as other.Greater than zero This instance follows otherin the sort order.
Day(double)
Creates the TimeValue struct with Day unit.
public static TimeValue Day(double value)
Parameters
valuedoubleThe value.
Returns
- TimeValue
The time value.
Day(NumberValue)
Creates the TimeValue struct with Day unit.
public static TimeValue Day(NumberValue value)
Parameters
valueNumberValueThe value.
Returns
- TimeValue
The time value.
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand this instance are the same type and represent the same value; otherwise, false.
Equals(TimeValue)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(TimeValue other)
Parameters
otherTimeValueAn object to compare with this object.
Returns
Floor(TimeValue)
Returns the largest integral value less than or equal to the specified value number.
public static TimeValue Floor(TimeValue value)
Parameters
valueTimeValueThe value.
Returns
- TimeValue
The largest integral value.
Frac(TimeValue)
Returns the fractional part of the value number.
public static TimeValue Frac(TimeValue value)
Parameters
valueTimeValueThe value number.
Returns
- TimeValue
The fractional part.
GetHashCode()
Returns the hash code for this instance.
[ExcludeFromCodeCoverage]
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
Hour(double)
Creates the TimeValue struct with Hour unit.
public static TimeValue Hour(double value)
Parameters
valuedoubleThe value.
Returns
- TimeValue
The time value.
Hour(NumberValue)
Creates the TimeValue struct with Hour unit.
public static TimeValue Hour(NumberValue value)
Parameters
valueNumberValueThe value.
Returns
- TimeValue
The time value.
Microsecond(double)
Creates the TimeValue struct with Microsecond unit.
public static TimeValue Microsecond(double value)
Parameters
valuedoubleThe value.
Returns
- TimeValue
The time value.
Microsecond(NumberValue)
Creates the TimeValue struct with Microsecond unit.
public static TimeValue Microsecond(NumberValue value)
Parameters
valueNumberValueThe value.
Returns
- TimeValue
The time value.
Millisecond(double)
Creates the TimeValue struct with Millisecond unit.
public static TimeValue Millisecond(double value)
Parameters
valuedoubleThe value.
Returns
- TimeValue
The time value.
Millisecond(NumberValue)
Creates the TimeValue struct with Millisecond unit.
public static TimeValue Millisecond(NumberValue value)
Parameters
valueNumberValueThe value.
Returns
- TimeValue
The time value.
Minute(double)
Creates the TimeValue struct with Minute unit.
public static TimeValue Minute(double value)
Parameters
valuedoubleThe value.
Returns
- TimeValue
The time value.
Minute(NumberValue)
Creates the TimeValue struct with Minute unit.
public static TimeValue Minute(NumberValue value)
Parameters
valueNumberValueThe value.
Returns
- TimeValue
The time value.
Nanosecond(double)
Creates the TimeValue struct with Nanosecond unit.
public static TimeValue Nanosecond(double value)
Parameters
valuedoubleThe value.
Returns
- TimeValue
The time value.
Nanosecond(NumberValue)
Creates the TimeValue struct with Nanosecond unit.
public static TimeValue Nanosecond(NumberValue value)
Parameters
valueNumberValueThe value.
Returns
- TimeValue
The time value.
Round(TimeValue, NumberValue)
Rounds a double-precision floating-point value to a specified number of fractional digits, and uses the specified rounding convention for midpoint values.
public static TimeValue Round(TimeValue timeValue, NumberValue digits)
Parameters
timeValueTimeValueThe number.
digitsNumberValueThe number of fractional digits in the return value.
Returns
- TimeValue
The number nearest to
timeValuethat has a number of fractional digits equal todigits. If value has fewer fractional digits thandigits,timeValueis returned unchanged.
Second(double)
Creates the TimeValue struct with Second unit.
public static TimeValue Second(double value)
Parameters
valuedoubleThe value.
Returns
- TimeValue
The time value.
Second(NumberValue)
Creates the TimeValue struct with Second unit.
public static TimeValue Second(NumberValue value)
Parameters
valueNumberValueThe value.
Returns
- TimeValue
The time value.
To(TimeUnit)
Convert to the newUnit unit.
public TimeValue To(TimeUnit newUnit)
Parameters
newUnitTimeUnitThe new unit.
Returns
- TimeValue
The value in the new unit.
ToDay()
Converts the value to the day unit.
public TimeValue ToDay()
Returns
- TimeValue
The value in day unit.
ToHour()
Converts the value to the hour unit.
public TimeValue ToHour()
Returns
- TimeValue
The value in hour unit.
ToMicrosecond()
Converts the value to the microsecond unit.
public TimeValue ToMicrosecond()
Returns
- TimeValue
The value in microsecond unit.
ToMillisecond()
Converts the value to the millisecond unit.
public TimeValue ToMillisecond()
Returns
- TimeValue
The value in millisecond unit.
ToMinute()
Converts the value to the minute unit.
public TimeValue ToMinute()
Returns
- TimeValue
The value in minute unit.
ToNanosecond()
Converts the value to the nanosecond unit.
public TimeValue ToNanosecond()
Returns
- TimeValue
The value in nanosecond unit.
ToSecond()
Converts the value to the second unit.
public TimeValue ToSecond()
Returns
- TimeValue
The value in second unit.
ToString()
Returns the fully qualified type name of this instance.
public override string ToString()
Returns
- string
The fully qualified type name.
ToWeek()
Converts the value to the week unit.
public TimeValue ToWeek()
Returns
- TimeValue
The value in week unit.
ToYear()
Converts the value to the year unit.
public TimeValue ToYear()
Returns
- TimeValue
The value in year unit.
Truncate(TimeValue)
Calculates the integral part of a specified value number.
public static TimeValue Truncate(TimeValue value)
Parameters
valueTimeValueAn value to truncate.
Returns
- TimeValue
The integral part of value number.
Week(double)
Creates the TimeValue struct with Week unit.
public static TimeValue Week(double value)
Parameters
valuedoubleThe value.
Returns
- TimeValue
The time value.
Week(NumberValue)
Creates the TimeValue struct with Week unit.
public static TimeValue Week(NumberValue value)
Parameters
valueNumberValueThe value.
Returns
- TimeValue
The time value.
Year(double)
Creates the TimeValue struct with Year unit.
public static TimeValue Year(double value)
Parameters
valuedoubleThe value.
Returns
- TimeValue
The time value.
Year(NumberValue)
Creates the TimeValue struct with Year unit.
public static TimeValue Year(NumberValue value)
Parameters
valueNumberValueThe value.
Returns
- TimeValue
The time value.
Operators
operator +(TimeValue, TimeValue)
Adds two objects of TimeValue.
public static TimeValue operator +(TimeValue left, TimeValue right)
Parameters
Returns
- TimeValue
An object that is the sum of
leftandright.
operator ==(TimeValue, TimeValue)
Determines whether two specified instances of TimeValue are equal.
public static bool operator ==(TimeValue left, TimeValue right)
Parameters
Returns
- bool
trueifleftis equal toright; otherwise,false.
operator >(TimeValue, TimeValue)
Indicates whether left parameter is greater than the right parameter.
public static bool operator >(TimeValue left, TimeValue right)
Parameters
Returns
- bool
trueif theleftparameter is greater than therightparameter; otherwise,false.
operator >=(TimeValue, TimeValue)
Indicates whether left parameter is greater than or equal to the right parameter.
public static bool operator >=(TimeValue left, TimeValue right)
Parameters
Returns
- bool
trueif theleftparameter is greater than or equal to therightparameter; otherwise,false.
operator !=(TimeValue, TimeValue)
Determines whether two specified instances of TimeValue are equal.
public static bool operator !=(TimeValue left, TimeValue right)
Parameters
Returns
- bool
trueifleftis equal toright; otherwise,false.
operator <(TimeValue, TimeValue)
Indicates whether left parameter is less than the right parameter.
public static bool operator <(TimeValue left, TimeValue right)
Parameters
Returns
- bool
trueif theleftparameter is less than therightparameter; otherwise,false.
operator <=(TimeValue, TimeValue)
Indicates whether left parameter is less than or equal to the right parameter.
public static bool operator <=(TimeValue left, TimeValue right)
Parameters
Returns
- bool
trueif theleftparameter is less than or equal to therightparameter; otherwise,false.
operator -(TimeValue, TimeValue)
Subtracts two objects of TimeValue.
public static TimeValue operator -(TimeValue left, TimeValue right)
Parameters
Returns
- TimeValue
An object that is the difference of
leftandright.
operator -(TimeValue)
Produces the negative of TimeValue.
public static TimeValue operator -(TimeValue value)
Parameters
valueTimeValueThe value.
Returns
- TimeValue
The negative of
value.