11 [__DynamicallyInvokable]
15 [__DynamicallyInvokable]
18 private const double MillisecondsPerTick = 0.0001;
21 [__DynamicallyInvokable]
24 private const double SecondsPerTick = 1
E-07;
27 [__DynamicallyInvokable]
30 private const double MinutesPerTick = 1.6666666666666667E-09;
33 [__DynamicallyInvokable]
36 private const double HoursPerTick = 2.7777777777777777E-11;
39 [__DynamicallyInvokable]
42 private const double DaysPerTick = 1.1574074074074074E-12;
44 private const int MillisPerSecond = 1000;
46 private const int MillisPerMinute = 60000;
48 private const int MillisPerHour = 3600000;
50 private const int MillisPerDay = 86400000;
52 internal const long MaxSeconds = 922337203685
L;
54 internal const long MinSeconds = -922337203685
L;
56 internal const long MaxMilliSeconds = 922337203685477
L;
58 internal const long MinMilliSeconds = -922337203685477
L;
60 internal const long TicksPerTenthSecond = 1000000
L;
63 [__DynamicallyInvokable]
67 [__DynamicallyInvokable]
71 [__DynamicallyInvokable]
76 private static volatile bool _legacyConfigChecked;
78 private static volatile bool _legacyMode;
82 [__DynamicallyInvokable]
85 [__DynamicallyInvokable]
94 [__DynamicallyInvokable]
97 [__DynamicallyInvokable]
100 return (
int)(_ticks / 864000000000
L);
106 [__DynamicallyInvokable]
109 [__DynamicallyInvokable]
112 return (
int)(_ticks / 36000000000
L % 24);
118 [__DynamicallyInvokable]
121 [__DynamicallyInvokable]
124 return (
int)(_ticks / 10000 % 1000);
130 [__DynamicallyInvokable]
133 [__DynamicallyInvokable]
136 return (
int)(_ticks / 600000000 % 60);
142 [__DynamicallyInvokable]
145 [__DynamicallyInvokable]
148 return (
int)(_ticks / 10000000 % 60);
154 [__DynamicallyInvokable]
157 [__DynamicallyInvokable]
160 return (
double)_ticks * 1.1574074074074074E-12;
166 [__DynamicallyInvokable]
169 [__DynamicallyInvokable]
172 return (
double)_ticks * 2.7777777777777777E-11;
178 [__DynamicallyInvokable]
181 [__DynamicallyInvokable]
184 double num = (double)_ticks * 0.0001;
185 if (num > 922337203685477.0)
187 return 922337203685477.0;
189 if (num < -922337203685477.0)
191 return -922337203685477.0;
199 [__DynamicallyInvokable]
202 [__DynamicallyInvokable]
205 return (
double)_ticks * 1.6666666666666667E-09;
211 [__DynamicallyInvokable]
214 [__DynamicallyInvokable]
217 return (
double)_ticks * 1
E-07;
221 private static bool LegacyMode
225 if (!_legacyConfigChecked)
227 _legacyMode = GetLegacyFormatMode();
228 _legacyConfigChecked =
true;
236 [__DynamicallyInvokable]
247 [__DynamicallyInvokable]
248 public TimeSpan(
int hours,
int minutes,
int seconds)
250 _ticks = TimeToTicks(hours, minutes, seconds);
259 [__DynamicallyInvokable]
260 public TimeSpan(
int days,
int hours,
int minutes,
int seconds)
262 this =
new TimeSpan(days, hours, minutes, seconds, 0);
272 [__DynamicallyInvokable]
273 public TimeSpan(
int days,
int hours,
int minutes,
int seconds,
int milliseconds)
275 long num = ((long)days * 3600
L * 24 + (
long)hours * 3600
L + (long)minutes * 60
L + seconds) * 1000 + milliseconds;
276 if (num > 922337203685477
L || num < -922337203685477
L)
280 _ticks = num * 10000;
288 [__DynamicallyInvokable]
291 long num = _ticks + ts._ticks;
292 if (_ticks >> 63 == ts._ticks >> 63 && _ticks >> 63 != num >> 63)
306 [__DynamicallyInvokable]
309 if (t1._ticks > t2._ticks)
313 if (t1._ticks < t2._ticks)
336 long ticks = ((
TimeSpan)value)._ticks;
351 [__DynamicallyInvokable]
354 long ticks = value._ticks;
375 [__DynamicallyInvokable]
378 return Interval(value, 86400000);
384 [__DynamicallyInvokable]
391 return new TimeSpan((_ticks >= 0) ? _ticks : (-_ticks));
398 [__DynamicallyInvokable]
399 public override bool Equals(
object value)
403 return _ticks == ((
TimeSpan)value)._ticks;
412 [__DynamicallyInvokable]
415 return _ticks == obj._ticks;
423 [__DynamicallyInvokable]
426 return t1._ticks == t2._ticks;
431 [__DynamicallyInvokable]
434 return (
int)_ticks ^ (int)(_ticks >> 32);
446 [__DynamicallyInvokable]
449 return Interval(value, 3600000);
452 private static TimeSpan Interval(
double value,
int scale)
454 if (
double.IsNaN(value))
458 double num = value * (double)scale;
459 double num2 = num + ((value >= 0.0) ? 0.5 : (-0.5));
460 if (num2 > 922337203685477.0 || num2 < -922337203685477.0)
462 throw new OverflowException(Environment.GetResourceString(
"Overflow_TimeSpanTooLong"));
464 return new TimeSpan((
long)num2 * 10000);
476 [__DynamicallyInvokable]
479 return Interval(value, 1);
491 [__DynamicallyInvokable]
494 return Interval(value, 60000);
500 [__DynamicallyInvokable]
519 [__DynamicallyInvokable]
522 return Interval(value, 1000);
530 [__DynamicallyInvokable]
533 long num = _ticks - ts._ticks;
534 if (_ticks >> 63 != ts._ticks >> 63 && _ticks >> 63 != num >> 63)
544 [__DynamicallyInvokable]
550 internal static long TimeToTicks(
int hour,
int minute,
int second)
552 long num = (long)hour * 3600
L + (
long)minute * 60
L + second;
553 if (num > 922337203685
L || num < -922337203685
L)
557 return num * 10000000;
569 [__DynamicallyInvokable]
572 return TimeSpanParse.
Parse(s,
null);
585 [__DynamicallyInvokable]
588 return TimeSpanParse.
Parse(input, formatProvider);
602 [__DynamicallyInvokable]
619 [__DynamicallyInvokable]
622 return TimeSpanParse.ParseExactMultiple(input, formats, formatProvider,
TimeSpanStyles.None);
639 [__DynamicallyInvokable]
642 TimeSpanParse.ValidateStyles(styles,
"styles");
643 return TimeSpanParse.
ParseExact(input, format, formatProvider, styles);
660 [__DynamicallyInvokable]
663 TimeSpanParse.ValidateStyles(styles,
"styles");
664 return TimeSpanParse.ParseExactMultiple(input, formats, formatProvider, styles);
672 [__DynamicallyInvokable]
675 return TimeSpanParse.TryParse(s,
null, out result);
684 [__DynamicallyInvokable]
687 return TimeSpanParse.TryParse(input, formatProvider, out result);
697 [__DynamicallyInvokable]
700 return TimeSpanParse.TryParseExact(input, format, formatProvider,
TimeSpanStyles.None, out result);
710 [__DynamicallyInvokable]
713 return TimeSpanParse.TryParseExactMultiple(input, formats, formatProvider,
TimeSpanStyles.None, out result);
724 [__DynamicallyInvokable]
727 TimeSpanParse.ValidateStyles(styles,
"styles");
728 return TimeSpanParse.TryParseExact(input, format, formatProvider, styles, out result);
739 [__DynamicallyInvokable]
742 TimeSpanParse.ValidateStyles(styles,
"styles");
743 return TimeSpanParse.TryParseExactMultiple(input, formats, formatProvider, styles, out result);
748 [__DynamicallyInvokable]
751 return TimeSpanFormat.Format(
this,
null,
null);
758 [__DynamicallyInvokable]
761 return TimeSpanFormat.Format(
this, format,
null);
769 [__DynamicallyInvokable]
774 return TimeSpanFormat.Format(
this,
null,
null);
776 return TimeSpanFormat.Format(
this, format, formatProvider);
783 [__DynamicallyInvokable]
798 [__DynamicallyInvokable]
807 [__DynamicallyInvokable]
818 [__DynamicallyInvokable]
829 [__DynamicallyInvokable]
832 return t1._ticks == t2._ticks;
840 [__DynamicallyInvokable]
843 return t1._ticks != t2._ticks;
851 [__DynamicallyInvokable]
854 return t1._ticks < t2._ticks;
862 [__DynamicallyInvokable]
865 return t1._ticks <= t2._ticks;
873 [__DynamicallyInvokable]
876 return t1._ticks > t2._ticks;
884 [__DynamicallyInvokable]
887 return t1._ticks >= t2._ticks;
892 private static extern bool LegacyFormatMode();
894 [SecuritySafeCritical]
895 private static bool GetLegacyFormatMode()
897 if (LegacyFormatMode())
901 return CompatibilitySwitches.IsNetFx40TimeSpanLegacyFormatMode;
static TimeSpan FromDays(double value)
Returns a T:System.TimeSpan that represents a specified number of days, where the specification is ac...
int Days
Gets the days component of the time interval represented by the current T:System.TimeSpan structure.
int Milliseconds
Gets the milliseconds component of the time interval represented by the current T:System....
static TimeSpan ParseExact(string input, string format, IFormatProvider formatProvider, TimeSpanStyles styles)
Converts the string representation of a time interval to its T:System.TimeSpan equivalent by using th...
static bool TryParseExact(string input, string[] formats, IFormatProvider formatProvider, out TimeSpan result)
Converts the specified string representation of a time interval to its T:System.TimeSpan equivalent b...
TimeSpan(long ticks)
Initializes a new instance of the T:System.TimeSpan structure to the specified number of ticks.
static TimeSpan Parse(string input, IFormatProvider formatProvider)
Converts the string representation of a time interval to its T:System.TimeSpan equivalent by using th...
static bool Equals(TimeSpan t1, TimeSpan t2)
Returns a value that indicates whether two specified instances of T:System.TimeSpan are equal.
bool Equals(TimeSpan obj)
Returns a value indicating whether this instance is equal to a specified T:System....
The exception that is thrown when the value of an argument is outside the allowable range of values a...
const long TicksPerDay
Represents the number of ticks in 1 day. This field is constant.
static bool operator >=(TimeSpan t1, TimeSpan t2)
Indicates whether a specified T:System.TimeSpan is greater than or equal to another specified T:Syste...
static bool TryParseExact(string input, string format, IFormatProvider formatProvider, out TimeSpan result)
Converts the string representation of a time interval to its T:System.TimeSpan equivalent by using th...
override int GetHashCode()
Returns a hash code for this instance.
double TotalMilliseconds
Gets the value of the current T:System.TimeSpan structure expressed in whole and fractional milliseco...
static TimeSpan FromSeconds(double value)
Returns a T:System.TimeSpan that represents a specified number of seconds, where the specification is...
TimeSpanStyles
Defines the formatting options that customize string parsing for the Overload:System....
double TotalMinutes
Gets the value of the current T:System.TimeSpan structure expressed in whole and fractional minutes.
static TimeSpan FromMilliseconds(double value)
Returns a T:System.TimeSpan that represents a specified number of milliseconds.
override bool Equals(object value)
Returns a value indicating whether this instance is equal to a specified object.
int Hours
Gets the hours component of the time interval represented by the current T:System....
static bool TryParse(string input, IFormatProvider formatProvider, out TimeSpan result)
Converts the string representation of a time interval to its T:System.TimeSpan equivalent by using th...
static bool operator<=(TimeSpan t1, TimeSpan t2)
Indicates whether a specified T:System.TimeSpan is less than or equal to another specified T:System....
Defines a generalized type-specific comparison method that a value type or class implements to order ...
static TimeSpan FromMinutes(double value)
Returns a T:System.TimeSpan that represents a specified number of minutes, where the specification is...
The exception that is thrown when an arithmetic, casting, or conversion operation in a checked contex...
static int Compare(TimeSpan t1, TimeSpan t2)
Compares two T:System.TimeSpan values and returns an integer that indicates whether the first value i...
long Ticks
Gets the number of ticks that represent the value of the current T:System.TimeSpan structure.
static TimeSpan ParseExact(string input, string[] formats, IFormatProvider formatProvider, TimeSpanStyles styles)
Converts the string representation of a time interval to its T:System.TimeSpan equivalent by using th...
int CompareTo(object value)
Compares this instance to a specified object and returns an integer that indicates whether this insta...
Provides information about, and means to manipulate, the current environment and platform....
const long TicksPerSecond
Represents the number of ticks in 1 second.
static TimeSpan FromTicks(long value)
Returns a T:System.TimeSpan that represents a specified time, where the specification is in units of ...
TimeSpan(int days, int hours, int minutes, int seconds)
Initializes a new instance of the T:System.TimeSpan structure to a specified number of days,...
double TotalSeconds
Gets the value of the current T:System.TimeSpan structure expressed in whole and fractional seconds.
int CompareTo(TimeSpan value)
Compares this instance to a specified T:System.TimeSpan object and returns an integer that indicates ...
static bool TryParse(string s, out TimeSpan result)
Converts the string representation of a time interval to its T:System.TimeSpan equivalent and returns...
int Minutes
Gets the minutes component of the time interval represented by the current T:System....
static TimeSpan operator -(TimeSpan t)
Returns a T:System.TimeSpan whose value is the negated value of the specified instance.
static bool operator==(TimeSpan t1, TimeSpan t2)
Indicates whether two T:System.TimeSpan instances are equal.
TimeSpan Duration()
Returns a new T:System.TimeSpan object whose value is the absolute value of the current T:System....
static TimeSpan operator+(TimeSpan t)
Returns the specified instance of T:System.TimeSpan.
static readonly TimeSpan Zero
Represents the zero T:System.TimeSpan value. This field is read-only.
MethodImplOptions
Defines the details of how a method is implemented.
TimeSpan Negate()
Returns a new T:System.TimeSpan object whose value is the negated value of this instance.
static TimeSpan FromHours(double value)
Returns a T:System.TimeSpan that represents a specified number of hours, where the specification is a...
static bool TryParseExact(string input, string[] formats, IFormatProvider formatProvider, TimeSpanStyles styles, out TimeSpan result)
Converts the specified string representation of a time interval to its T:System.TimeSpan equivalent b...
static readonly TimeSpan MaxValue
Represents the maximum T:System.TimeSpan value. This field is read-only.
static bool operator >(TimeSpan t1, TimeSpan t2)
Indicates whether a specified T:System.TimeSpan is greater than another specified T:System....
The exception that is thrown when one of the arguments provided to a method is not valid.
static TimeSpan ParseExact(string input, string format, IFormatProvider formatProvider)
Converts the string representation of a time interval to its T:System.TimeSpan equivalent by using th...
override string ToString()
Converts the value of the current T:System.TimeSpan object to its equivalent string representation.
static readonly TimeSpan MinValue
Represents the minimum T:System.TimeSpan value. This field is read-only.
static TimeSpan Parse(string s)
Converts the string representation of a time interval to its T:System.TimeSpan equivalent.
Defines a generalized method that a value type or class implements to create a type-specific method f...
string ToString(string format, IFormatProvider formatProvider)
Converts the value of the current T:System.TimeSpan object to its equivalent string representation by...
static bool operator !=(TimeSpan t1, TimeSpan t2)
Indicates whether two T:System.TimeSpan instances are not equal.
Represents a time interval.To browse the .NET Framework source code for this type,...
static bool operator<(TimeSpan t1, TimeSpan t2)
Indicates whether a specified T:System.TimeSpan is less than another specified T:System....
TimeSpan(int hours, int minutes, int seconds)
Initializes a new instance of the T:System.TimeSpan structure to a specified number of hours,...
Specifies that the class can be serialized.
static bool TryParseExact(string input, string format, IFormatProvider formatProvider, TimeSpanStyles styles, out TimeSpan result)
Converts the string representation of a time interval to its T:System.TimeSpan equivalent by using th...
const long TicksPerMillisecond
Represents the number of ticks in 1 millisecond. This field is constant.
string ToString(string format)
Converts the value of the current T:System.TimeSpan object to its equivalent string representation by...
static TimeSpan ParseExact(string input, string[] formats, IFormatProvider formatProvider)
Converts the string representation of a time interval to its T:System.TimeSpan equivalent by using th...
TimeSpan(int days, int hours, int minutes, int seconds, int milliseconds)
Initializes a new instance of the T:System.TimeSpan structure to a specified number of days,...
int Seconds
Gets the seconds component of the time interval represented by the current T:System....
double TotalHours
Gets the value of the current T:System.TimeSpan structure expressed in whole and fractional hours.
static TimeSpan operator -(TimeSpan t1, TimeSpan t2)
Subtracts a specified T:System.TimeSpan from another specified T:System.TimeSpan.
TimeSpan Add(TimeSpan ts)
Returns a new T:System.TimeSpan object whose value is the sum of the specified T:System....
const long TicksPerMinute
Represents the number of ticks in 1 minute. This field is constant.
TimeSpan Subtract(TimeSpan ts)
Returns a new T:System.TimeSpan object whose value is the difference between the specified T:System....
const long TicksPerHour
Represents the number of ticks in 1 hour. This field is constant.
double TotalDays
Gets the value of the current T:System.TimeSpan structure expressed in whole and fractional days.