9public readonly
struct TimeSpan :
IComparable,
IComparable<TimeSpan>,
IEquatable<TimeSpan>,
ISpanFormattable,
IFormattable,
IAdditionOperators<TimeSpan, TimeSpan, TimeSpan>,
IAdditiveIdentity<TimeSpan, TimeSpan>,
IComparisonOperators<TimeSpan, TimeSpan>,
IEqualityOperators<TimeSpan, TimeSpan>,
IDivisionOperators<TimeSpan, double, TimeSpan>,
IDivisionOperators<TimeSpan, TimeSpan, double>,
IMinMaxValue<TimeSpan>,
IMultiplyOperators<TimeSpan, double, TimeSpan>,
IMultiplicativeIdentity<TimeSpan, double>,
ISpanParseable<TimeSpan>,
IParseable<TimeSpan>,
ISubtractionOperators<TimeSpan, TimeSpan, TimeSpan>,
IUnaryNegationOperators<TimeSpan, TimeSpan>,
IUnaryPlusOperators<TimeSpan, TimeSpan>
49 double num = (double)
_ticks / 10000.0;
50 if (num > 922337203685477.0)
52 return 922337203685477.0;
54 if (num < -922337203685477.0)
56 return -922337203685477.0;
66 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
69 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
72 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
75 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
83 public TimeSpan(
int hours,
int minutes,
int seconds)
88 public TimeSpan(
int days,
int hours,
int minutes,
int seconds)
89 : this(days, hours, minutes, seconds, 0)
93 public TimeSpan(
int days,
int hours,
int minutes,
int seconds,
int milliseconds)
95 long num = ((long)days * 3600
L * 24 + (
long)hours * 3600
L + (long)minutes * 60
L + seconds) * 1000 + milliseconds;
96 if (num > 922337203685477
L || num < -922337203685477
L)
150 long ticks =
value._ticks;
192 return t1._ticks == t2.
_ticks;
207 if (
double.IsNaN(
value))
211 double ticks =
value * scale;
217 if (ticks > 9.223372036854776
E+18 || ticks < -9.223372036854776
E+18 ||
double.IsNaN(ticks))
221 if (ticks == 9.223372036854776
E+18)
264 return this * factor;
269 return this / divisor;
283 internal static long TimeToTicks(
int hour,
int minute,
int second)
285 long num = (long)hour * 3600
L + (
long)minute * 60
L + second;
286 if (num > 922337203685
L || num < -922337203685
L)
290 return num * 10000000;
522 if (
double.IsNaN(factor))
532 return timeSpan * factor;
537 if (
double.IsNaN(divisor))
547 return (
double)t1.Ticks / (double)t2.
Ticks;
552 return t1._ticks == t2.
_ticks;
557 return t1._ticks != t2.
_ticks;
562 return t1._ticks < t2.
_ticks;
567 return t1._ticks <= t2.
_ticks;
572 return t1._ticks > t2.
_ticks;
577 return t1._ticks >= t2.
_ticks;
580 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
586 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
592 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
595 return left <= right;
598 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
604 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
607 return left >= right;
610 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
616 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
622 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
625 return left == right;
628 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
631 return left != right;
634 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
640 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
643 return Parse(
s, provider);
646 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
649 return TryParse(
s, provider, out result);
652 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
655 return Parse(
s, provider);
658 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
661 return TryParse(
s, provider, out result);
664 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
670 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
676 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
static TimeSpan Parse(ReadOnlySpan< char > input, IFormatProvider formatProvider)
static TimeSpan ParseExactMultiple(ReadOnlySpan< char > input, string[] formats, IFormatProvider formatProvider, TimeSpanStyles styles)
static bool TryParseExactMultiple(ReadOnlySpan< char > input, string[] formats, IFormatProvider formatProvider, TimeSpanStyles styles, out TimeSpan result)
static bool TryParseExact(ReadOnlySpan< char > input, ReadOnlySpan< char > format, IFormatProvider formatProvider, TimeSpanStyles styles, out TimeSpan result)
static TimeSpan ParseExact(ReadOnlySpan< char > input, ReadOnlySpan< char > format, IFormatProvider formatProvider, TimeSpanStyles styles)
static bool TryParse(ReadOnlySpan< char > input, IFormatProvider formatProvider, out TimeSpan result)
static decimal Round(decimal d)
static string Overflow_NegateTwosCompNum
static string Arg_MustBeTimeSpan
static string Overflow_Duration
static string Argument_InvalidTimeSpanStyles
static string Overflow_TimeSpanTooLong
static string Arg_CannotBeNaN
static void ThrowArgumentNullException(string name)
static void ThrowArgumentOutOfRange_TimeSpanTooLong()
static TResult AdditiveIdentity
static TResult MultiplicativeIdentity
static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, out TSelf result)
static TSelf Parse(string s, IFormatProvider? provider)
static bool TryParse(ReadOnlySpan< char > s, IFormatProvider? provider, out TSelf result)
static TSelf Parse(ReadOnlySpan< char > s, IFormatProvider? provider)
static TimeSpan ParseExact(string input, string format, IFormatProvider? formatProvider, TimeSpanStyles styles)
TimeSpan(int days, int hours, int minutes, int seconds)
static bool TryParseExact(ReadOnlySpan< char > input, [NotNullWhen(true)] string?[]? formats, IFormatProvider? formatProvider, TimeSpanStyles styles, out TimeSpan result)
static TimeSpan operator-(TimeSpan t)
const long TicksPerMinute
static TimeSpan Parse(string input, IFormatProvider? formatProvider)
static bool operator>=(TimeSpan t1, TimeSpan t2)
bool TryFormat(Span< char > destination, out int charsWritten, ReadOnlySpan< char > format=default(ReadOnlySpan< char >), IFormatProvider? formatProvider=null)
static TimeSpan ParseExact(ReadOnlySpan< char > input, string[] formats, IFormatProvider? formatProvider, TimeSpanStyles styles=TimeSpanStyles.None)
TimeSpan(int hours, int minutes, int seconds)
static bool TryParseExact([NotNullWhen(true)] string? input, [NotNullWhen(true)] string?[]? formats, IFormatProvider? formatProvider, TimeSpanStyles styles, out TimeSpan result)
static readonly TimeSpan MinValue
static bool TryParseExact([NotNullWhen(true)] string? input, [NotNullWhen(true)] string? format, IFormatProvider? formatProvider, TimeSpanStyles styles, out TimeSpan result)
static int Compare(TimeSpan t1, TimeSpan t2)
static TimeSpan Parse(ReadOnlySpan< char > input, IFormatProvider? formatProvider=null)
static bool TryParseExact(ReadOnlySpan< char > input, ReadOnlySpan< char > format, IFormatProvider? formatProvider, TimeSpanStyles styles, out TimeSpan result)
static void ValidateStyles(TimeSpanStyles style, string parameterName)
TimeSpan(int days, int hours, int minutes, int seconds, int milliseconds)
static bool TryParse(ReadOnlySpan< char > s, out TimeSpan result)
static bool TryParse([NotNullWhen(true)] string? s, out TimeSpan result)
static TimeSpan IMinMaxValue< TimeSpan >. MinValue
static bool operator>(TimeSpan t1, TimeSpan t2)
static bool TryParse(ReadOnlySpan< char > input, IFormatProvider? formatProvider, out TimeSpan result)
TimeSpan Multiply(double factor)
double Divide(TimeSpan ts)
static TimeSpan Interval(double value, double scale)
static bool operator<=(TimeSpan t1, TimeSpan t2)
static readonly TimeSpan MaxValue
static TimeSpan FromMilliseconds(double value)
static TimeSpan ParseExact(string input, string[] formats, IFormatProvider? formatProvider)
static bool operator<(TimeSpan t1, TimeSpan t2)
const long TicksPerMillisecond
static bool TryParseExact(ReadOnlySpan< char > input, [NotNullWhen(true)] string?[]? formats, IFormatProvider? formatProvider, out TimeSpan result)
static TimeSpan FromSeconds(double value)
static TimeSpan operator*(TimeSpan timeSpan, double factor)
static TimeSpan IMinMaxValue< TimeSpan >. MaxValue
static TimeSpan ParseExact(ReadOnlySpan< char > input, ReadOnlySpan< char > format, IFormatProvider? formatProvider, TimeSpanStyles styles=TimeSpanStyles.None)
bool Equals(TimeSpan obj)
static TimeSpan operator+(TimeSpan t)
static TimeSpan ParseExact(string input, string[] formats, IFormatProvider? formatProvider, TimeSpanStyles styles)
static readonly TimeSpan Zero
override int GetHashCode()
static bool TryParse([NotNullWhen(true)] string? input, IFormatProvider? formatProvider, out TimeSpan result)
int CompareTo(object? value)
static TimeSpan FromDays(double value)
static bool TryParseExact([NotNullWhen(true)] string? input, [NotNullWhen(true)] string?[]? formats, IFormatProvider? formatProvider, out TimeSpan result)
static bool operator==(TimeSpan t1, TimeSpan t2)
static TimeSpan IntervalFromDoubleTicks(double ticks)
int CompareTo(TimeSpan value)
TimeSpan Subtract(TimeSpan ts)
static bool operator!=(TimeSpan t1, TimeSpan t2)
static bool TryParseExact(ReadOnlySpan< char > input, ReadOnlySpan< char > format, IFormatProvider? formatProvider, out TimeSpan result)
static bool TryParseExact([NotNullWhen(true)] string? input, [NotNullWhen(true)] string? format, IFormatProvider? formatProvider, out TimeSpan result)
static TimeSpan FromTicks(long value)
override bool Equals([NotNullWhen(true)] object? value)
static TimeSpan FromHours(double value)
string ToString(string? format, IFormatProvider? formatProvider)
TimeSpan Divide(double divisor)
static TimeSpan Parse(string s)
override string ToString()
const long TicksPerSecond
static TimeSpan ParseExact(string input, string format, IFormatProvider? formatProvider)
static bool Equals(TimeSpan t1, TimeSpan t2)
static long TimeToTicks(int hour, int minute, int second)
static TimeSpan operator/(TimeSpan timeSpan, double divisor)
static TimeSpan FromMinutes(double value)
TimeSpan Add(TimeSpan ts)
string ToString(string? format)