Files
Dec2017-Script-Dump/mscorlib/System/TimeSpan.cs
T
2026-06-04 11:42:34 +02:00

937 lines
41 KiB
C#

using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
namespace System
{
/// <summary>Represents a time interval.</summary>
/// <filterpriority>1</filterpriority>
// Token: 0x020006AF RID: 1711
[ComVisible(true)]
[Serializable]
public struct TimeSpan : IComparable, IComparable<TimeSpan>, IEquatable<TimeSpan>
{
/// <summary>Initializes a new <see cref="T:System.TimeSpan" /> to the specified number of ticks.</summary>
/// <param name="ticks">A time period expressed in 100-nanosecond units. </param>
// Token: 0x060040A6 RID: 16550 RVA: 0x000DC15C File Offset: 0x000DA35C
public TimeSpan(long ticks)
{
this._ticks = ticks;
}
/// <summary>Initializes a new <see cref="T:System.TimeSpan" /> to a specified number of hours, minutes, and seconds.</summary>
/// <param name="hours">Number of hours. </param>
/// <param name="minutes">Number of minutes. </param>
/// <param name="seconds">Number of seconds. </param>
/// <exception cref="T:System.ArgumentOutOfRangeException">The parameters specify a <see cref="T:System.TimeSpan" /> value less than <see cref="F:System.TimeSpan.MinValue" /> or greater than <see cref="F:System.TimeSpan.MaxValue" />. </exception>
// Token: 0x060040A7 RID: 16551 RVA: 0x000DC168 File Offset: 0x000DA368
public TimeSpan(int hours, int minutes, int seconds)
{
this._ticks = TimeSpan.CalculateTicks(0, hours, minutes, seconds, 0);
}
/// <summary>Initializes a new <see cref="T:System.TimeSpan" /> to a specified number of days, hours, minutes, and seconds.</summary>
/// <param name="days">Number of days. </param>
/// <param name="hours">Number of hours. </param>
/// <param name="minutes">Number of minutes. </param>
/// <param name="seconds">Number of seconds. </param>
/// <exception cref="T:System.ArgumentOutOfRangeException">The parameters specify a <see cref="T:System.TimeSpan" /> value less than <see cref="F:System.TimeSpan.MinValue" /> or greater than <see cref="F:System.TimeSpan.MaxValue" />. </exception>
// Token: 0x060040A8 RID: 16552 RVA: 0x000DC17C File Offset: 0x000DA37C
public TimeSpan(int days, int hours, int minutes, int seconds)
{
this._ticks = TimeSpan.CalculateTicks(days, hours, minutes, seconds, 0);
}
/// <summary>Initializes a new <see cref="T:System.TimeSpan" /> to a specified number of days, hours, minutes, seconds, and milliseconds.</summary>
/// <param name="days">Number of days. </param>
/// <param name="hours">Number of hours. </param>
/// <param name="minutes">Number of minutes. </param>
/// <param name="seconds">Number of seconds. </param>
/// <param name="milliseconds">Number of milliseconds. </param>
/// <exception cref="T:System.ArgumentOutOfRangeException">The parameters specify a <see cref="T:System.TimeSpan" /> value less than <see cref="F:System.TimeSpan.MinValue" /> or greater than <see cref="F:System.TimeSpan.MaxValue" />. </exception>
// Token: 0x060040A9 RID: 16553 RVA: 0x000DC190 File Offset: 0x000DA390
public TimeSpan(int days, int hours, int minutes, int seconds, int milliseconds)
{
this._ticks = TimeSpan.CalculateTicks(days, hours, minutes, seconds, milliseconds);
}
// Token: 0x060040AA RID: 16554 RVA: 0x000DC1A4 File Offset: 0x000DA3A4
static TimeSpan()
{
if (MonoTouchAOTHelper.FalseFlag)
{
GenericComparer<TimeSpan> genericComparer = new GenericComparer<TimeSpan>();
GenericEqualityComparer<TimeSpan> genericEqualityComparer = new GenericEqualityComparer<TimeSpan>();
}
}
// Token: 0x060040AB RID: 16555 RVA: 0x000DC1FC File Offset: 0x000DA3FC
internal static long CalculateTicks(int days, int hours, int minutes, int seconds, int milliseconds)
{
int num = hours * 3600;
int num2 = minutes * 60;
long num3 = (long)(num + num2 + seconds) * 1000L + (long)milliseconds;
num3 *= 10000L;
bool flag = false;
if (days > 0)
{
long num4 = 864000000000L * (long)days;
if (num3 < 0L)
{
long num5 = num3;
num3 += num4;
flag = num5 > num3;
}
else
{
num3 += num4;
flag = num3 < 0L;
}
}
else if (days < 0)
{
long num6 = 864000000000L * (long)days;
if (num3 <= 0L)
{
num3 += num6;
flag = num3 > 0L;
}
else
{
long num7 = num3;
num3 += num6;
flag = num3 > num7;
}
}
if (flag)
{
throw new ArgumentOutOfRangeException(Locale.GetText("The timespan is too big or too small."));
}
return num3;
}
/// <summary>Gets the days component of the time interval represented by the current <see cref="T:System.TimeSpan" /> structure.</summary>
/// <returns>The day component of this instance. The return value can be positive or negative.</returns>
/// <filterpriority>1</filterpriority>
// Token: 0x17000BEE RID: 3054
// (get) Token: 0x060040AC RID: 16556 RVA: 0x000DC2C8 File Offset: 0x000DA4C8
public int Days
{
get
{
return (int)(this._ticks / 864000000000L);
}
}
/// <summary>Gets the hours component of the time interval represented by the current <see cref="T:System.TimeSpan" /> structure.</summary>
/// <returns>The hour component of the current <see cref="T:System.TimeSpan" /> structure. The return value ranges from -23 through 23.</returns>
/// <filterpriority>1</filterpriority>
// Token: 0x17000BEF RID: 3055
// (get) Token: 0x060040AD RID: 16557 RVA: 0x000DC2DC File Offset: 0x000DA4DC
public int Hours
{
get
{
return (int)(this._ticks % 864000000000L / 36000000000L);
}
}
/// <summary>Gets the milliseconds component of the time interval represented by the current <see cref="T:System.TimeSpan" /> structure.</summary>
/// <returns>The millisecond component of the current <see cref="T:System.TimeSpan" /> structure. The return value ranges from -999 through 999.</returns>
/// <filterpriority>1</filterpriority>
// Token: 0x17000BF0 RID: 3056
// (get) Token: 0x060040AE RID: 16558 RVA: 0x000DC2FC File Offset: 0x000DA4FC
public int Milliseconds
{
get
{
return (int)(this._ticks % 10000000L / 10000L);
}
}
/// <summary>Gets the minutes component of the time interval represented by the current <see cref="T:System.TimeSpan" /> structure.</summary>
/// <returns>The minute component of the current <see cref="T:System.TimeSpan" /> structure. The return value ranges from -59 through 59.</returns>
/// <filterpriority>1</filterpriority>
// Token: 0x17000BF1 RID: 3057
// (get) Token: 0x060040AF RID: 16559 RVA: 0x000DC314 File Offset: 0x000DA514
public int Minutes
{
get
{
return (int)(this._ticks % 36000000000L / 600000000L);
}
}
/// <summary>Gets the seconds component of the time interval represented by the current <see cref="T:System.TimeSpan" /> structure.</summary>
/// <returns>The second component of the current <see cref="T:System.TimeSpan" /> structure. The return value ranges from -59 through 59.</returns>
/// <filterpriority>1</filterpriority>
// Token: 0x17000BF2 RID: 3058
// (get) Token: 0x060040B0 RID: 16560 RVA: 0x000DC330 File Offset: 0x000DA530
public int Seconds
{
get
{
return (int)(this._ticks % 600000000L / 10000000L);
}
}
/// <summary>Gets the number of ticks that represent the value of the current <see cref="T:System.TimeSpan" /> structure.</summary>
/// <returns>The number of ticks contained in this instance.</returns>
/// <filterpriority>1</filterpriority>
// Token: 0x17000BF3 RID: 3059
// (get) Token: 0x060040B1 RID: 16561 RVA: 0x000DC348 File Offset: 0x000DA548
public long Ticks
{
get
{
return this._ticks;
}
}
/// <summary>Gets the value of the current <see cref="T:System.TimeSpan" /> structure expressed in whole and fractional days.</summary>
/// <returns>The total number of days represented by this instance.</returns>
/// <filterpriority>1</filterpriority>
// Token: 0x17000BF4 RID: 3060
// (get) Token: 0x060040B2 RID: 16562 RVA: 0x000DC350 File Offset: 0x000DA550
public double TotalDays
{
get
{
return (double)this._ticks / 864000000000.0;
}
}
/// <summary>Gets the value of the current <see cref="T:System.TimeSpan" /> structure expressed in whole and fractional hours.</summary>
/// <returns>The total number of hours represented by this instance.</returns>
/// <filterpriority>1</filterpriority>
// Token: 0x17000BF5 RID: 3061
// (get) Token: 0x060040B3 RID: 16563 RVA: 0x000DC364 File Offset: 0x000DA564
public double TotalHours
{
get
{
return (double)this._ticks / 36000000000.0;
}
}
/// <summary>Gets the value of the current <see cref="T:System.TimeSpan" /> structure expressed in whole and fractional milliseconds.</summary>
/// <returns>The total number of milliseconds represented by this instance.</returns>
/// <filterpriority>1</filterpriority>
// Token: 0x17000BF6 RID: 3062
// (get) Token: 0x060040B4 RID: 16564 RVA: 0x000DC378 File Offset: 0x000DA578
public double TotalMilliseconds
{
get
{
return (double)this._ticks / 10000.0;
}
}
/// <summary>Gets the value of the current <see cref="T:System.TimeSpan" /> structure expressed in whole and fractional minutes.</summary>
/// <returns>The total number of minutes represented by this instance.</returns>
/// <filterpriority>1</filterpriority>
// Token: 0x17000BF7 RID: 3063
// (get) Token: 0x060040B5 RID: 16565 RVA: 0x000DC38C File Offset: 0x000DA58C
public double TotalMinutes
{
get
{
return (double)this._ticks / 600000000.0;
}
}
/// <summary>Gets the value of the current <see cref="T:System.TimeSpan" /> structure expressed in whole and fractional seconds.</summary>
/// <returns>The total number of seconds represented by this instance.</returns>
/// <filterpriority>1</filterpriority>
// Token: 0x17000BF8 RID: 3064
// (get) Token: 0x060040B6 RID: 16566 RVA: 0x000DC3A0 File Offset: 0x000DA5A0
public double TotalSeconds
{
get
{
return (double)this._ticks / 10000000.0;
}
}
/// <summary>Returns a new <see cref="T:System.TimeSpan" /> object whose value is the sum of the specified <see cref="T:System.TimeSpan" /> object and this instance.</summary>
/// <returns>A new object that represents the value of this instance plus the value of <paramref name="ts" />.</returns>
/// <param name="ts">A <see cref="T:System.TimeSpan" />. </param>
/// <exception cref="T:System.OverflowException">The resulting <see cref="T:System.TimeSpan" /> is less than <see cref="F:System.TimeSpan.MinValue" /> or greater than <see cref="F:System.TimeSpan.MaxValue" />. </exception>
/// <filterpriority>1</filterpriority>
// Token: 0x060040B7 RID: 16567 RVA: 0x000DC3B4 File Offset: 0x000DA5B4
public TimeSpan Add(TimeSpan ts)
{
TimeSpan timeSpan;
try
{
timeSpan = new TimeSpan(checked(this._ticks + ts.Ticks));
}
catch (OverflowException)
{
throw new OverflowException(Locale.GetText("Resulting timespan is too big."));
}
return timeSpan;
}
/// <summary>Compares two <see cref="T:System.TimeSpan" /> values and returns an integer that indicates whether the first value is shorter than, equal to, or longer than the second value.</summary>
/// <returns>Value Condition -1 <paramref name="t1" /> is shorter than <paramref name="t2" />0 <paramref name="t1" /> is equal to <paramref name="t2" />1 <paramref name="t1" /> is longer than <paramref name="t2" /></returns>
/// <param name="t1">A <see cref="T:System.TimeSpan" />. </param>
/// <param name="t2">A <see cref="T:System.TimeSpan" />. </param>
/// <filterpriority>1</filterpriority>
// Token: 0x060040B8 RID: 16568 RVA: 0x000DC414 File Offset: 0x000DA614
public static int Compare(TimeSpan t1, TimeSpan t2)
{
if (t1._ticks < t2._ticks)
{
return -1;
}
if (t1._ticks > t2._ticks)
{
return 1;
}
return 0;
}
/// <summary>Compares this instance to a specified object and returns an integer that indicates whether this instance is shorter than, equal to, or longer than the specified object.</summary>
/// <returns>Value Condition -1 This instance is shorter than <paramref name="value" />. 0 This instance is equal to <paramref name="value" />. 1 This instance is longer than <paramref name="value" />.-or- <paramref name="value" /> is null. </returns>
/// <param name="value">An object to compare, or null. </param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="value" /> is not a <see cref="T:System.TimeSpan" />. </exception>
/// <filterpriority>1</filterpriority>
// Token: 0x060040B9 RID: 16569 RVA: 0x000DC444 File Offset: 0x000DA644
public int CompareTo(object value)
{
if (value == null)
{
return 1;
}
if (!(value is TimeSpan))
{
throw new ArgumentException(Locale.GetText("Argument has to be a TimeSpan."), "value");
}
return TimeSpan.Compare(this, (TimeSpan)value);
}
/// <summary>Compares this instance to a specified <see cref="T:System.TimeSpan" /> object and returns an integer that indicates whether this instance is shorter than, equal to, or longer than the <see cref="T:System.TimeSpan" /> object.</summary>
/// <returns>A signed number indicating the relative values of this instance and <paramref name="value" />.Value Description A negative integer This instance is shorter than <paramref name="value" />. Zero This instance is equal to <paramref name="value" />. A positive integer This instance is longer than <paramref name="value" />. </returns>
/// <param name="value">A <see cref="T:System.TimeSpan" /> object to compare to this instance.</param>
/// <filterpriority>1</filterpriority>
// Token: 0x060040BA RID: 16570 RVA: 0x000DC480 File Offset: 0x000DA680
public int CompareTo(TimeSpan value)
{
return TimeSpan.Compare(this, value);
}
/// <summary>Returns a value indicating whether this instance is equal to a specified <see cref="T:System.TimeSpan" /> object.</summary>
/// <returns>true if <paramref name="obj" /> represents the same time interval as this instance; otherwise, false.</returns>
/// <param name="obj">An <see cref="T:System.TimeSpan" /> object to compare with this instance. </param>
/// <filterpriority>1</filterpriority>
// Token: 0x060040BB RID: 16571 RVA: 0x000DC490 File Offset: 0x000DA690
public bool Equals(TimeSpan obj)
{
return obj._ticks == this._ticks;
}
/// <summary>Returns a new <see cref="T:System.TimeSpan" /> object whose value is the absolute value of the current <see cref="T:System.TimeSpan" /> object.</summary>
/// <returns>A new object whose value is the absolute value of the current <see cref="T:System.TimeSpan" /> object.</returns>
/// <exception cref="T:System.OverflowException">The value of this instance is <see cref="F:System.TimeSpan.MinValue" />. </exception>
/// <filterpriority>1</filterpriority>
// Token: 0x060040BC RID: 16572 RVA: 0x000DC4A4 File Offset: 0x000DA6A4
public TimeSpan Duration()
{
TimeSpan timeSpan;
try
{
timeSpan = new TimeSpan(Math.Abs(this._ticks));
}
catch (OverflowException)
{
throw new OverflowException(Locale.GetText("This TimeSpan value is MinValue so you cannot get the duration."));
}
return timeSpan;
}
/// <summary>Returns a value indicating whether this instance is equal to a specified object.</summary>
/// <returns>true if <paramref name="value" /> is a <see cref="T:System.TimeSpan" /> object that represents the same time interval as the current <see cref="T:System.TimeSpan" /> structure; otherwise, false.</returns>
/// <param name="value">An object to compare with this instance. </param>
/// <filterpriority>1</filterpriority>
// Token: 0x060040BD RID: 16573 RVA: 0x000DC500 File Offset: 0x000DA700
public override bool Equals(object value)
{
return value is TimeSpan && this._ticks == ((TimeSpan)value)._ticks;
}
/// <summary>Returns a value indicating whether two specified instances of <see cref="T:System.TimeSpan" /> are equal.</summary>
/// <returns>true if the values of <paramref name="t1" /> and <paramref name="t2" /> are equal; otherwise, false.</returns>
/// <param name="t1">A <see cref="T:System.TimeSpan" />. </param>
/// <param name="t2">A TimeSpan. </param>
/// <filterpriority>1</filterpriority>
// Token: 0x060040BE RID: 16574 RVA: 0x000DC530 File Offset: 0x000DA730
public static bool Equals(TimeSpan t1, TimeSpan t2)
{
return t1._ticks == t2._ticks;
}
/// <summary>Returns a <see cref="T:System.TimeSpan" /> that represents a specified number of days, where the specification is accurate to the nearest millisecond.</summary>
/// <returns>A <see cref="T:System.TimeSpan" /> that represents <paramref name="value" />.</returns>
/// <param name="value">A number of days, accurate to the nearest millisecond. </param>
/// <exception cref="T:System.OverflowException">
/// <paramref name="value" /> is less than <see cref="F:System.TimeSpan.MinValue" /> or greater than <see cref="F:System.TimeSpan.MaxValue" />. -or-<paramref name="value" /> is <see cref="F:System.Double.PositiveInfinity" />.-or-<paramref name="value" /> is <see cref="F:System.Double.NegativeInfinity" />.</exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="value" /> is equal to <see cref="F:System.Double.NaN" />. </exception>
/// <filterpriority>1</filterpriority>
// Token: 0x060040BF RID: 16575 RVA: 0x000DC544 File Offset: 0x000DA744
public static TimeSpan FromDays(double value)
{
return TimeSpan.From(value, 864000000000L);
}
/// <summary>Returns a <see cref="T:System.TimeSpan" /> that represents a specified number of hours, where the specification is accurate to the nearest millisecond.</summary>
/// <returns>A <see cref="T:System.TimeSpan" /> that represents <paramref name="value" />.</returns>
/// <param name="value">A number of hours accurate to the nearest millisecond. </param>
/// <exception cref="T:System.OverflowException">
/// <paramref name="value" /> is less than <see cref="F:System.TimeSpan.MinValue" /> or greater than <see cref="F:System.TimeSpan.MaxValue" />. -or-<paramref name="value" /> is <see cref="F:System.Double.PositiveInfinity" />.-or-<paramref name="value" /> is <see cref="F:System.Double.NegativeInfinity" />.</exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="value" /> is equal to <see cref="F:System.Double.NaN" />. </exception>
/// <filterpriority>1</filterpriority>
// Token: 0x060040C0 RID: 16576 RVA: 0x000DC558 File Offset: 0x000DA758
public static TimeSpan FromHours(double value)
{
return TimeSpan.From(value, 36000000000L);
}
/// <summary>Returns a <see cref="T:System.TimeSpan" /> that represents a specified number of minutes, where the specification is accurate to the nearest millisecond.</summary>
/// <returns>A <see cref="T:System.TimeSpan" /> that represents <paramref name="value" />.</returns>
/// <param name="value">A number of minutes, accurate to the nearest millisecond. </param>
/// <exception cref="T:System.OverflowException">
/// <paramref name="value" /> is less than <see cref="F:System.TimeSpan.MinValue" /> or greater than <see cref="F:System.TimeSpan.MaxValue" />.-or-<paramref name="value" /> is <see cref="F:System.Double.PositiveInfinity" />.-or-<paramref name="value" /> is <see cref="F:System.Double.NegativeInfinity" />. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="value" /> is equal to <see cref="F:System.Double.NaN" />. </exception>
/// <filterpriority>1</filterpriority>
// Token: 0x060040C1 RID: 16577 RVA: 0x000DC56C File Offset: 0x000DA76C
public static TimeSpan FromMinutes(double value)
{
return TimeSpan.From(value, 600000000L);
}
/// <summary>Returns a <see cref="T:System.TimeSpan" /> that represents a specified number of seconds, where the specification is accurate to the nearest millisecond.</summary>
/// <returns>A <see cref="T:System.TimeSpan" /> that represents <paramref name="value" />.</returns>
/// <param name="value">A number of seconds, accurate to the nearest millisecond. </param>
/// <exception cref="T:System.OverflowException">
/// <paramref name="value" /> is less than <see cref="F:System.TimeSpan.MinValue" /> or greater than <see cref="F:System.TimeSpan.MaxValue" />.-or-<paramref name="value" /> is <see cref="F:System.Double.PositiveInfinity" />.-or-<paramref name="value" /> is <see cref="F:System.Double.NegativeInfinity" />. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="value" /> is equal to <see cref="F:System.Double.NaN" />. </exception>
/// <filterpriority>1</filterpriority>
// Token: 0x060040C2 RID: 16578 RVA: 0x000DC57C File Offset: 0x000DA77C
public static TimeSpan FromSeconds(double value)
{
return TimeSpan.From(value, 10000000L);
}
/// <summary>Returns a <see cref="T:System.TimeSpan" /> that represents a specified number of milliseconds.</summary>
/// <returns>A <see cref="T:System.TimeSpan" /> that represents <paramref name="value" />.</returns>
/// <param name="value">A number of milliseconds. </param>
/// <exception cref="T:System.OverflowException">
/// <paramref name="value" /> is less than <see cref="F:System.TimeSpan.MinValue" /> or greater than <see cref="F:System.TimeSpan.MaxValue" />.-or-<paramref name="value" /> is <see cref="F:System.Double.PositiveInfinity" />.-or-<paramref name="value" /> is <see cref="F:System.Double.NegativeInfinity" />. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="value" /> is equal to <see cref="F:System.Double.NaN" />. </exception>
/// <filterpriority>1</filterpriority>
// Token: 0x060040C3 RID: 16579 RVA: 0x000DC58C File Offset: 0x000DA78C
public static TimeSpan FromMilliseconds(double value)
{
return TimeSpan.From(value, 10000L);
}
// Token: 0x060040C4 RID: 16580 RVA: 0x000DC59C File Offset: 0x000DA79C
private static TimeSpan From(double value, long tickMultiplicator)
{
if (double.IsNaN(value))
{
throw new ArgumentException(Locale.GetText("Value cannot be NaN."), "value");
}
if (double.IsNegativeInfinity(value) || double.IsPositiveInfinity(value) || value < (double)TimeSpan.MinValue.Ticks || value > (double)TimeSpan.MaxValue.Ticks)
{
throw new OverflowException(Locale.GetText("Outside range [MinValue,MaxValue]"));
}
TimeSpan timeSpan;
try
{
value *= (double)(tickMultiplicator / 10000L);
checked
{
long num = (long)Math.Round(value);
timeSpan = new TimeSpan(num * 10000L);
}
}
catch (OverflowException)
{
throw new OverflowException(Locale.GetText("Resulting timespan is too big."));
}
return timeSpan;
}
/// <summary>Returns a <see cref="T:System.TimeSpan" /> that represents a specified time, where the specification is in units of ticks.</summary>
/// <returns>A <see cref="T:System.TimeSpan" /> with a value of <paramref name="value" />.</returns>
/// <param name="value">A number of ticks that represent a time. </param>
/// <filterpriority>1</filterpriority>
// Token: 0x060040C5 RID: 16581 RVA: 0x000DC678 File Offset: 0x000DA878
public static TimeSpan FromTicks(long value)
{
return new TimeSpan(value);
}
/// <summary>Returns a hash code for this instance.</summary>
/// <returns>A 32-bit signed integer hash code.</returns>
/// <filterpriority>2</filterpriority>
// Token: 0x060040C6 RID: 16582 RVA: 0x000DC680 File Offset: 0x000DA880
public override int GetHashCode()
{
return this._ticks.GetHashCode();
}
/// <summary>Returns a new <see cref="T:System.TimeSpan" /> object whose value is the negated value of this instance.</summary>
/// <returns>A new object with the same numeric value as this instance, but with the opposite sign.</returns>
/// <exception cref="T:System.OverflowException">The negated value of this instance cannot be represented by a <see cref="T:System.TimeSpan" />; that is, the value of this instance is <see cref="F:System.TimeSpan.MinValue" />. </exception>
/// <filterpriority>1</filterpriority>
// Token: 0x060040C7 RID: 16583 RVA: 0x000DC690 File Offset: 0x000DA890
public TimeSpan Negate()
{
if (this._ticks == TimeSpan.MinValue._ticks)
{
throw new OverflowException(Locale.GetText("This TimeSpan value is MinValue and cannot be negated."));
}
return new TimeSpan(-this._ticks);
}
/// <summary>Constructs a new <see cref="T:System.TimeSpan" /> object from a time interval specified in a string.</summary>
/// <returns>A <see cref="T:System.TimeSpan" /> that corresponds to <paramref name="s" />.</returns>
/// <param name="s">A string that specifies a time interval. </param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="s" /> is null. </exception>
/// <exception cref="T:System.FormatException">
/// <paramref name="s" /> has an invalid format. </exception>
/// <exception cref="T:System.OverflowException">
/// <paramref name="s" /> represents a number less than <see cref="F:System.TimeSpan.MinValue" /> or greater than <see cref="F:System.TimeSpan.MaxValue" />.-or- At least one of the days, hours, minutes, or seconds components is outside its valid range. </exception>
/// <filterpriority>1</filterpriority>
// Token: 0x060040C8 RID: 16584 RVA: 0x000DC6D4 File Offset: 0x000DA8D4
public static TimeSpan Parse(string s)
{
if (s == null)
{
throw new ArgumentNullException("s");
}
TimeSpan.Parser parser = new TimeSpan.Parser(s);
return parser.Execute();
}
/// <summary>Constructs a new <see cref="T:System.TimeSpan" /> object from a time interval specified in a string. Parameters specify the time interval and the variable where the new <see cref="T:System.TimeSpan" /> object is returned. </summary>
/// <returns>true if <paramref name="s" /> was converted successfully; otherwise, false. This operation returns false if the <paramref name="s" /> parameter is null, has an invalid format, represents a time interval less than <see cref="F:System.TimeSpan.MinValue" /> or greater than <see cref="F:System.TimeSpan.MaxValue" />, or has at least one days, hours, minutes, or seconds component outside its valid range.</returns>
/// <param name="s">A string that specifies a time interval.</param>
/// <param name="result">When this method returns, contains an object that represents the time interval specified by <paramref name="s" />, or <see cref="F:System.TimeSpan.Zero" /> if the conversion failed. This parameter is passed uninitialized.</param>
/// <filterpriority>1</filterpriority>
// Token: 0x060040C9 RID: 16585 RVA: 0x000DC700 File Offset: 0x000DA900
public static bool TryParse(string s, out TimeSpan result)
{
if (s == null)
{
result = TimeSpan.Zero;
return false;
}
bool flag;
try
{
result = TimeSpan.Parse(s);
flag = true;
}
catch
{
result = TimeSpan.Zero;
flag = false;
}
return flag;
}
/// <summary>Returns a new <see cref="T:System.TimeSpan" /> object whose value is the difference between the specified <see cref="T:System.TimeSpan" /> object and this instance.</summary>
/// <returns>A new time interval whose value is the result of the value of this instance minus the value of <paramref name="ts" />.</returns>
/// <param name="ts">A <see cref="T:System.TimeSpan" />. </param>
/// <exception cref="T:System.OverflowException">The return value is less than <see cref="F:System.TimeSpan.MinValue" /> or greater than <see cref="F:System.TimeSpan.MaxValue" />. </exception>
/// <filterpriority>1</filterpriority>
// Token: 0x060040CA RID: 16586 RVA: 0x000DC770 File Offset: 0x000DA970
public TimeSpan Subtract(TimeSpan ts)
{
TimeSpan timeSpan;
try
{
timeSpan = new TimeSpan(checked(this._ticks - ts.Ticks));
}
catch (OverflowException)
{
throw new OverflowException(Locale.GetText("Resulting timespan is too big."));
}
return timeSpan;
}
/// <summary>Returns the string representation of the value of this instance.</summary>
/// <returns>A string that represents the value of this instance. The return value is of the form: [-][d.]hh:mm:ss[.fffffff] Elements in square brackets ([ and ]) may not be included in the returned string. Colons and periods (: and.) are literal characters. The non-literal elements are listed in the following table.Item Description "-" A minus sign, which indicates a negative time span. No sign is included for a positive time span."d" The number of days in the time span. This element is omitted if the time span is less than one day. "hh" The number of hours in the time span, ranging from 0 to 23. "mm" The number of minutes in the time span, ranging from 0 to 59. "ss" The number of seconds in the time span, ranging from 0 to 59. "fffffff" Fractional seconds in the time span. This element is omitted if the time span does not include fractional seconds. If present, fractional seconds are always expressed using 7 decimal digits. Note:For more information about comparing the string representation of <see cref="T:System.TimeSpan" /> and Oracle data types, see article Q324577, "System.TimeSpan Does Not Match Oracle 9i INTERVAL DAY TO SECOND Data Type," in the Microsoft Knowledge Base at http://support.microsoft.com.</returns>
/// <filterpriority>1</filterpriority>
// Token: 0x060040CB RID: 16587 RVA: 0x000DC7D0 File Offset: 0x000DA9D0
public override string ToString()
{
StringBuilder stringBuilder = new StringBuilder(14);
if (this._ticks < 0L)
{
stringBuilder.Append('-');
}
if (this.Days != 0)
{
stringBuilder.Append(Math.Abs(this.Days));
stringBuilder.Append('.');
}
stringBuilder.Append(Math.Abs(this.Hours).ToString("D2"));
stringBuilder.Append(':');
stringBuilder.Append(Math.Abs(this.Minutes).ToString("D2"));
stringBuilder.Append(':');
stringBuilder.Append(Math.Abs(this.Seconds).ToString("D2"));
int num = (int)Math.Abs(this._ticks % 10000000L);
if (num != 0)
{
stringBuilder.Append('.');
stringBuilder.Append(num.ToString("D7"));
}
return stringBuilder.ToString();
}
/// <summary>Adds two specified <see cref="T:System.TimeSpan" /> instances.</summary>
/// <returns>A <see cref="T:System.TimeSpan" /> whose value is the sum of the values of <paramref name="t1" /> and <paramref name="t2" />.</returns>
/// <param name="t1">A <see cref="T:System.TimeSpan" />. </param>
/// <param name="t2">A <see cref="T:System.TimeSpan" />. </param>
/// <exception cref="T:System.OverflowException">The resulting <see cref="T:System.TimeSpan" /> is less than <see cref="F:System.TimeSpan.MinValue" /> or greater than <see cref="F:System.TimeSpan.MaxValue" />. </exception>
/// <filterpriority>3</filterpriority>
// Token: 0x060040CC RID: 16588 RVA: 0x000DC8D0 File Offset: 0x000DAAD0
public static TimeSpan operator +(TimeSpan t1, TimeSpan t2)
{
return t1.Add(t2);
}
/// <summary>Indicates whether two <see cref="T:System.TimeSpan" /> instances are equal.</summary>
/// <returns>true if the values of <paramref name="t1" /> and <paramref name="t2" /> are equal; otherwise, false.</returns>
/// <param name="t1">A <see cref="T:System.TimeSpan" />. </param>
/// <param name="t2">A TimeSpan. </param>
/// <filterpriority>3</filterpriority>
// Token: 0x060040CD RID: 16589 RVA: 0x000DC8DC File Offset: 0x000DAADC
public static bool operator ==(TimeSpan t1, TimeSpan t2)
{
return t1._ticks == t2._ticks;
}
/// <summary>Indicates whether a specified <see cref="T:System.TimeSpan" /> is greater than another specified <see cref="T:System.TimeSpan" />.</summary>
/// <returns>true if the value of <paramref name="t1" /> is greater than the value of <paramref name="t2" />; otherwise, false.</returns>
/// <param name="t1">A <see cref="T:System.TimeSpan" />. </param>
/// <param name="t2">A TimeSpan. </param>
/// <filterpriority>3</filterpriority>
// Token: 0x060040CE RID: 16590 RVA: 0x000DC8F0 File Offset: 0x000DAAF0
public static bool operator >(TimeSpan t1, TimeSpan t2)
{
return t1._ticks > t2._ticks;
}
/// <summary>Indicates whether a specified <see cref="T:System.TimeSpan" /> is greater than or equal to another specified <see cref="T:System.TimeSpan" />.</summary>
/// <returns>true if the value of <paramref name="t1" /> is greater than or equal to the value of <paramref name="t2" />; otherwise, false.</returns>
/// <param name="t1">A <see cref="T:System.TimeSpan" />. </param>
/// <param name="t2">A TimeSpan. </param>
/// <filterpriority>3</filterpriority>
// Token: 0x060040CF RID: 16591 RVA: 0x000DC904 File Offset: 0x000DAB04
public static bool operator >=(TimeSpan t1, TimeSpan t2)
{
return t1._ticks >= t2._ticks;
}
/// <summary>Indicates whether two <see cref="T:System.TimeSpan" /> instances are not equal.</summary>
/// <returns>true if the values of <paramref name="t1" /> and <paramref name="t2" /> are not equal; otherwise, false.</returns>
/// <param name="t1">A <see cref="T:System.TimeSpan" />. </param>
/// <param name="t2">A TimeSpan. </param>
/// <filterpriority>3</filterpriority>
// Token: 0x060040D0 RID: 16592 RVA: 0x000DC91C File Offset: 0x000DAB1C
public static bool operator !=(TimeSpan t1, TimeSpan t2)
{
return t1._ticks != t2._ticks;
}
/// <summary>Indicates whether a specified <see cref="T:System.TimeSpan" /> is less than another specified <see cref="T:System.TimeSpan" />.</summary>
/// <returns>true if the value of <paramref name="t1" /> is less than the value of <paramref name="t2" />; otherwise, false.</returns>
/// <param name="t1">A <see cref="T:System.TimeSpan" />. </param>
/// <param name="t2">A TimeSpan. </param>
/// <filterpriority>3</filterpriority>
// Token: 0x060040D1 RID: 16593 RVA: 0x000DC934 File Offset: 0x000DAB34
public static bool operator <(TimeSpan t1, TimeSpan t2)
{
return t1._ticks < t2._ticks;
}
/// <summary>Indicates whether a specified <see cref="T:System.TimeSpan" /> is less than or equal to another specified <see cref="T:System.TimeSpan" />.</summary>
/// <returns>true if the value of <paramref name="t1" /> is less than or equal to the value of <paramref name="t2" />; otherwise, false.</returns>
/// <param name="t1">A <see cref="T:System.TimeSpan" />. </param>
/// <param name="t2">A TimeSpan. </param>
/// <filterpriority>3</filterpriority>
// Token: 0x060040D2 RID: 16594 RVA: 0x000DC948 File Offset: 0x000DAB48
public static bool operator <=(TimeSpan t1, TimeSpan t2)
{
return t1._ticks <= t2._ticks;
}
/// <summary>Subtracts a specified <see cref="T:System.TimeSpan" /> from another specified <see cref="T:System.TimeSpan" />.</summary>
/// <returns>A TimeSpan whose value is the result of the value of <paramref name="t1" /> minus the value of <paramref name="t2" />.</returns>
/// <param name="t1">A <see cref="T:System.TimeSpan" />. </param>
/// <param name="t2">A TimeSpan. </param>
/// <exception cref="T:System.OverflowException">The return value is less than <see cref="F:System.TimeSpan.MinValue" /> or greater than <see cref="F:System.TimeSpan.MaxValue" />. </exception>
/// <filterpriority>3</filterpriority>
// Token: 0x060040D3 RID: 16595 RVA: 0x000DC960 File Offset: 0x000DAB60
public static TimeSpan operator -(TimeSpan t1, TimeSpan t2)
{
return t1.Subtract(t2);
}
/// <summary>Returns a <see cref="T:System.TimeSpan" /> whose value is the negated value of the specified instance.</summary>
/// <returns>A <see cref="T:System.TimeSpan" /> with the same numeric value as this instance, but the opposite sign.</returns>
/// <param name="t">A <see cref="T:System.TimeSpan" />. </param>
/// <exception cref="T:System.OverflowException">The negated value of this instance cannot be represented by a <see cref="T:System.TimeSpan" />; that is, the value of this instance is <see cref="F:System.TimeSpan.MinValue" />. </exception>
/// <filterpriority>3</filterpriority>
// Token: 0x060040D4 RID: 16596 RVA: 0x000DC96C File Offset: 0x000DAB6C
public static TimeSpan operator -(TimeSpan t)
{
return t.Negate();
}
/// <summary>Returns the specified instance of <see cref="T:System.TimeSpan" />.</summary>
/// <returns>Returns <paramref name="t" />.</returns>
/// <param name="t">A <see cref="T:System.TimeSpan" />. </param>
/// <filterpriority>3</filterpriority>
// Token: 0x060040D5 RID: 16597 RVA: 0x000DC978 File Offset: 0x000DAB78
public static TimeSpan operator +(TimeSpan t)
{
return t;
}
/// <summary>Represents the number of ticks in 1 day. This field is constant.</summary>
/// <filterpriority>1</filterpriority>
// Token: 0x040019E2 RID: 6626
public const long TicksPerDay = 864000000000L;
/// <summary>Represents the number of ticks in 1 hour. This field is constant.</summary>
/// <filterpriority>1</filterpriority>
// Token: 0x040019E3 RID: 6627
public const long TicksPerHour = 36000000000L;
/// <summary>Represents the number of ticks in 1 millisecond. This field is constant.</summary>
/// <filterpriority>1</filterpriority>
// Token: 0x040019E4 RID: 6628
public const long TicksPerMillisecond = 10000L;
/// <summary>Represents the number of ticks in 1 minute. This field is constant.</summary>
/// <filterpriority>1</filterpriority>
// Token: 0x040019E5 RID: 6629
public const long TicksPerMinute = 600000000L;
/// <summary>Represents the number of ticks in 1 second.</summary>
/// <filterpriority>1</filterpriority>
// Token: 0x040019E6 RID: 6630
public const long TicksPerSecond = 10000000L;
/// <summary>Represents the maximum <see cref="T:System.TimeSpan" /> value. This field is read-only.</summary>
/// <filterpriority>1</filterpriority>
// Token: 0x040019E7 RID: 6631
public static readonly TimeSpan MaxValue = new TimeSpan(long.MaxValue);
/// <summary>Represents the minimum <see cref="T:System.TimeSpan" /> value. This field is read-only.</summary>
/// <filterpriority>1</filterpriority>
// Token: 0x040019E8 RID: 6632
public static readonly TimeSpan MinValue = new TimeSpan(long.MinValue);
/// <summary>Represents the zero <see cref="T:System.TimeSpan" /> value. This field is read-only.</summary>
/// <filterpriority>1</filterpriority>
// Token: 0x040019E9 RID: 6633
public static readonly TimeSpan Zero = new TimeSpan(0L);
// Token: 0x040019EA RID: 6634
private long _ticks;
// Token: 0x020006B0 RID: 1712
private class Parser
{
// Token: 0x060040D6 RID: 16598 RVA: 0x000DC97C File Offset: 0x000DAB7C
public Parser(string src)
{
this._src = src;
this._length = this._src.Length;
}
// Token: 0x17000BF9 RID: 3065
// (get) Token: 0x060040D7 RID: 16599 RVA: 0x000DC99C File Offset: 0x000DAB9C
public bool AtEnd
{
get
{
return this._cur >= this._length;
}
}
// Token: 0x060040D8 RID: 16600 RVA: 0x000DC9B0 File Offset: 0x000DABB0
private void ParseWhiteSpace()
{
while (!this.AtEnd && char.IsWhiteSpace(this._src, this._cur))
{
this._cur++;
}
}
// Token: 0x060040D9 RID: 16601 RVA: 0x000DC9F4 File Offset: 0x000DABF4
private bool ParseSign()
{
bool flag = false;
if (!this.AtEnd && this._src[this._cur] == '-')
{
flag = true;
this._cur++;
}
return flag;
}
// Token: 0x060040DA RID: 16602 RVA: 0x000DCA38 File Offset: 0x000DAC38
private int ParseInt(bool optional)
{
if (optional && this.AtEnd)
{
return 0;
}
int num = 0;
int num2 = 0;
while (!this.AtEnd && char.IsDigit(this._src, this._cur))
{
num = checked(num * 10 + (int)this._src[this._cur] - 48);
this._cur++;
num2++;
}
if (!optional && num2 == 0)
{
this.formatError = true;
}
return num;
}
// Token: 0x060040DB RID: 16603 RVA: 0x000DCAC4 File Offset: 0x000DACC4
private bool ParseOptDot()
{
if (this.AtEnd)
{
return false;
}
if (this._src[this._cur] == '.')
{
this._cur++;
return true;
}
return false;
}
// Token: 0x060040DC RID: 16604 RVA: 0x000DCB08 File Offset: 0x000DAD08
private void ParseOptColon()
{
if (!this.AtEnd)
{
if (this._src[this._cur] == ':')
{
this._cur++;
}
else
{
this.formatError = true;
}
}
}
// Token: 0x060040DD RID: 16605 RVA: 0x000DCB48 File Offset: 0x000DAD48
private long ParseTicks()
{
long num = 1000000L;
long num2 = 0L;
bool flag = false;
while (num > 0L && !this.AtEnd && char.IsDigit(this._src, this._cur))
{
num2 += (long)(this._src[this._cur] - '0') * num;
this._cur++;
num /= 10L;
flag = true;
}
if (!flag)
{
this.formatError = true;
}
return num2;
}
// Token: 0x060040DE RID: 16606 RVA: 0x000DCBD0 File Offset: 0x000DADD0
public TimeSpan Execute()
{
int num = 0;
this.ParseWhiteSpace();
bool flag = this.ParseSign();
int num2 = this.ParseInt(false);
if (this.ParseOptDot())
{
num = this.ParseInt(true);
}
else if (!this.AtEnd)
{
num = num2;
num2 = 0;
}
this.ParseOptColon();
int num3 = this.ParseInt(true);
this.ParseOptColon();
int num4 = this.ParseInt(true);
long num5;
if (this.ParseOptDot())
{
num5 = this.ParseTicks();
}
else
{
num5 = 0L;
}
this.ParseWhiteSpace();
if (!this.AtEnd)
{
this.formatError = true;
}
if (num > 23 || num3 > 59 || num4 > 59)
{
throw new OverflowException(Locale.GetText("Invalid time data."));
}
if (this.formatError)
{
throw new FormatException(Locale.GetText("Invalid format for TimeSpan.Parse."));
}
long num6 = TimeSpan.CalculateTicks(num2, num, num3, num4, 0);
checked
{
num6 = ((!flag) ? (num6 + num5) : ((long)(unchecked((ulong)0) - (ulong)num6 - (ulong)num5)));
return new TimeSpan(num6);
}
}
// Token: 0x040019EB RID: 6635
private string _src;
// Token: 0x040019EC RID: 6636
private int _cur;
// Token: 0x040019ED RID: 6637
private int _length;
// Token: 0x040019EE RID: 6638
private bool formatError;
}
}
}