Struct TimePeriod
Represents a time interval defined in years, months, days, hours, minutes, and seconds.
Inherited Members
Namespace: Nevatech.Vsb.Repository
Assembly: Nevatech.Vsb.Repository.dll
Syntax
public struct TimePeriod : IEquatable<TimePeriod>, IComparable<TimePeriod>
Constructors
TimePeriod(TimeUnit, Int32)
Initializes new instance from provided time interval.
Declaration
public TimePeriod(TimeUnit timeUnit, int timeInterval)
Parameters
Type | Name | Description |
---|---|---|
TimeUnit | timeUnit | Unit of time interval measure. |
Int32 | timeInterval | Length of the time interval in time units. |
TimePeriod(Int32, Int32, Int32)
Initializes new instance with provided number of years, months, and days.
Declaration
public TimePeriod(int years, int months, int days)
Parameters
Type | Name | Description |
---|---|---|
Int32 | years | The number of years in the period. |
Int32 | months | The number of months in the period. |
Int32 | days | The number of days in the period. |
TimePeriod(Int32, Int32, Int32, Int32, Int32, Int32)
Initializes new instance with provided number of years, months, and days.
Declaration
public TimePeriod(int years, int months, int days, int hours, int minutes, int seconds)
Parameters
Type | Name | Description |
---|---|---|
Int32 | years | The number of years in the period. |
Int32 | months | The number of months in the period. |
Int32 | days | The number of days in the period. |
Int32 | hours | The number of hours in the period. |
Int32 | minutes | The number of minutes in the period. |
Int32 | seconds | The number of seconds in the period. |
Fields
Zero
Gets zero-length time interval.
Declaration
public static readonly TimePeriod Zero
Field Value
Type | Description |
---|---|
TimePeriod |
Properties
Days
Gets or sets the number of days in the period.
Declaration
public int Days { get; set; }
Property Value
Type | Description |
---|---|
Int32 |
Hours
Gets or sets the number of hours in the period.
Declaration
public int Hours { get; set; }
Property Value
Type | Description |
---|---|
Int32 |
Minutes
Gets or sets the number of minutes in the period.
Declaration
public int Minutes { get; set; }
Property Value
Type | Description |
---|---|
Int32 |
Months
Gets or sets the number of months in the period.
Declaration
public int Months { get; set; }
Property Value
Type | Description |
---|---|
Int32 |
Seconds
Gets or sets the number of seconds in the period.
Declaration
public int Seconds { get; set; }
Property Value
Type | Description |
---|---|
Int32 |
Years
Gets or sets the number of years in the period.
Declaration
public int Years { get; set; }
Property Value
Type | Description |
---|---|
Int32 |
Methods
Add(DateTime)
Adds current time interval to provided date/time instance.
Declaration
public DateTime Add(DateTime dateTime)
Parameters
Type | Name | Description |
---|---|---|
DateTime | dateTime | Date/time instance which current time interval needs to be added to. |
Returns
Type | Description |
---|---|
DateTime | The result of addition current time interval to provided date/time. |
CompareTo(TimePeriod)
Compares the current object with another object of the same type. This method uses current UTC date and time as the start time to compare two instances.
Declaration
public int CompareTo(TimePeriod other)
Parameters
Type | Name | Description |
---|---|---|
TimePeriod | other | An object to compare with this object. |
Returns
Type | Description |
---|---|
Int32 | A 32-bit signed integer that indicates the relative order of the objects being compared. The return value has the following meanings: Value Meaning Less than zero This object is less than the other parameter. Zero This object is equal to other. Greater than zero This object is greater than other. |
CompareTo(TimePeriod, DateTime)
Compares the current object with another object of the same type. This method uses provided date and time to compare two instances.
Declaration
public int CompareTo(TimePeriod other, DateTime startDateTime)
Parameters
Type | Name | Description |
---|---|---|
TimePeriod | other | An object to compare with this object. |
DateTime | startDateTime | Start date/time to be used to compare two instances. Value of each instance is added to this date and then resulting dates are compared. |
Returns
Type | Description |
---|---|
Int32 | A 32-bit signed integer that indicates the relative order of the objects being compared. The return value has the following meanings: Value Meaning Less than zero This object is less than the other parameter. Zero This object is equal to other. Greater than zero This object is greater than other. |
Equals(TimePeriod)
Determines whether the specified object is equal to the current object.
Declaration
public bool Equals(TimePeriod other)
Parameters
Type | Name | Description |
---|---|---|
TimePeriod | other | The object to compare with the current object. |
Returns
Type | Description |
---|---|
Boolean | True, if objects are equal. False, if objects are not equal. |
Equals(Object)
Determines whether the specified object is equal to the current object.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
Object | obj | The object to compare with the current object. |
Returns
Type | Description |
---|---|
Boolean | True, if objects are equal. False, if objects are not equal. |
Overrides
GetHashCode()
Returns the hash code for this instance.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 | Hash code of the current instance. |
Overrides
Subtract(DateTime)
Subtracts current time interval from provided date/time instance.
Declaration
public DateTime Subtract(DateTime dateTime)
Parameters
Type | Name | Description |
---|---|---|
DateTime | dateTime | Date/time instance which current time interval needs to be subtracted from. |
Returns
Type | Description |
---|---|
DateTime | The result of subtraction current time interval from provided date/time. |
Operators
Equality(TimePeriod, TimePeriod)
Returns True, if provided time periods are equal. False, otherwise.
Declaration
public static bool operator ==(TimePeriod period1, TimePeriod period2)
Parameters
Type | Name | Description |
---|---|---|
TimePeriod | period1 | First time period to compare. |
TimePeriod | period2 | Second time period to compare. |
Returns
Type | Description |
---|---|
Boolean | Returns True, if provided time periods are equal. False, otherwise. |
GreaterThan(TimePeriod, TimePeriod)
Returns True, if the first period is greater than the second one. False, otherwise.
Declaration
public static bool operator>(TimePeriod period1, TimePeriod period2)
Parameters
Type | Name | Description |
---|---|---|
TimePeriod | period1 | First time period to compare. |
TimePeriod | period2 | Second time period to compare. |
Returns
Type | Description |
---|---|
Boolean | Returns True, if the first period is greater than the second one. False, otherwise. |
GreaterThanOrEqual(TimePeriod, TimePeriod)
Returns True, if the first period is greater or equal than the second one. False, otherwise.
Declaration
public static bool operator >=(TimePeriod period1, TimePeriod period2)
Parameters
Type | Name | Description |
---|---|---|
TimePeriod | period1 | First time period to compare. |
TimePeriod | period2 | Second time period to compare. |
Returns
Type | Description |
---|---|
Boolean | Returns True, if the first period is greater or equal than the second one. False, otherwise. |
Inequality(TimePeriod, TimePeriod)
Returns True, if provided time periods are NOT equal. False, otherwise.
Declaration
public static bool operator !=(TimePeriod period1, TimePeriod period2)
Parameters
Type | Name | Description |
---|---|---|
TimePeriod | period1 | First time period to compare. |
TimePeriod | period2 | Second time period to compare. |
Returns
Type | Description |
---|---|
Boolean | Returns True, if provided time periods are NOT equal. False, otherwise. |
LessThan(TimePeriod, TimePeriod)
Returns True, if the first period is less than the second one. False, otherwise.
Declaration
public static bool operator <(TimePeriod period1, TimePeriod period2)
Parameters
Type | Name | Description |
---|---|---|
TimePeriod | period1 | First time period to compare. |
TimePeriod | period2 | Second time period to compare. |
Returns
Type | Description |
---|---|
Boolean | Returns True, if the first period is less than the second one. False, otherwise. |
LessThanOrEqual(TimePeriod, TimePeriod)
Returns True, if the first period is less or equal than the second one. False, otherwise.
Declaration
public static bool operator <=(TimePeriod period1, TimePeriod period2)
Parameters
Type | Name | Description |
---|---|---|
TimePeriod | period1 | First time period to compare. |
TimePeriod | period2 | Second time period to compare. |
Returns
Type | Description |
---|---|
Boolean | Returns True, if the first period is less or equal than the second one. False, otherwise. |