Struct NpgsqlTimeSpan
Represents the PostgreSQL interval datatype.
Implements
Inherited Members
Namespace: NpgsqlTypes
Assembly: Npgsql.dll
Syntax
[Obsolete("For values outside the range of TimeSpan, consider using NodaTime (range -9998 to 9999), or read the value as an NpgsqlInterval. See https://www.npgsql.org/doc/types/datetime.html for more information.")]
[Serializable]
public readonly struct NpgsqlTimeSpan : IComparable, IComparer, IEquatable<NpgsqlTimeSpan>, IComparable<NpgsqlTimeSpan>, IComparer<NpgsqlTimeSpan>
Remarks
PostgreSQL differs from .NET in how it's interval type doesn't assume 24 hours in a day (to deal with 23- and 25-hour days caused by daylight savings adjustments) and has a concept of months that doesn't exist in .NET's TimeSpan class. (Neither datatype has any concessions for leap-seconds).
For most uses just casting to and from TimeSpan will work correctly — in particular, the results of subtracting one DateTime or the PostgreSQL date, time and timestamp types from another should be the same whether you do so in .NET or PostgreSQL — but if the handling of days and months in PostgreSQL is important to your application then you should use this class instead of TimeSpan.
If you don't know whether these differences are important to your application, they probably arent! Just use TimeSpan and do not use this class directly ☺
To avoid forcing unnecessary provider-specific concerns on users who need not be concerned with them a call to GetValue(Int32) on a field containing an NpgsqlTimeSpan value will return a TimeSpan rather than an NpgsqlTimeSpan. If you need the extra functionality of NpgsqlTimeSpan then use GetInterval(Int32).
Constructors
NpgsqlTimeSpan(Int32, Int32, Int32, Int32)
Initializes a new NpgsqlTimeSpan to the specified number of days, hours, minutes & seconds.
Declaration
public NpgsqlTimeSpan(int days, int hours, int minutes, int seconds)
Parameters
Type | Name | Description |
---|---|---|
Int32 | days | Number of days. |
Int32 | hours | Number of hours. |
Int32 | minutes | Number of minutes. |
Int32 | seconds | Number of seconds. |
NpgsqlTimeSpan(Int32, Int32, Int32, Int32, Int32)
Initializes a new NpgsqlTimeSpan to the specified number of days, hours, minutes, seconds & milliseconds.
Declaration
public NpgsqlTimeSpan(int days, int hours, int minutes, int seconds, int milliseconds)
Parameters
Type | Name | Description |
---|---|---|
Int32 | days | Number of days. |
Int32 | hours | Number of hours. |
Int32 | minutes | Number of minutes. |
Int32 | seconds | Number of seconds. |
Int32 | milliseconds | Number of milliseconds. |
NpgsqlTimeSpan(Int32, Int32, Int32, Int32, Int32, Int32)
Initializes a new NpgsqlTimeSpan to the specified number of months, days, hours, minutes, seconds & milliseconds.
Declaration
public NpgsqlTimeSpan(int months, int days, int hours, int minutes, int seconds, int milliseconds)
Parameters
Type | Name | Description |
---|---|---|
Int32 | months | Number of months. |
Int32 | days | Number of days. |
Int32 | hours | Number of hours. |
Int32 | minutes | Number of minutes. |
Int32 | seconds | Number of seconds. |
Int32 | milliseconds | Number of milliseconds. |
NpgsqlTimeSpan(Int32, Int32, Int32, Int32, Int32, Int32, Int32)
Initializes a new NpgsqlTimeSpan to the specified number of years, months, days, hours, minutes, seconds & milliseconds.
Years are calculated exactly equivalent to 12 months.
Declaration
public NpgsqlTimeSpan(int years, int months, int days, int hours, int minutes, int seconds, int milliseconds)
Parameters
Type | Name | Description |
---|---|---|
Int32 | years | Number of years. |
Int32 | months | Number of months. |
Int32 | days | Number of days. |
Int32 | hours | Number of hours. |
Int32 | minutes | Number of minutes. |
Int32 | seconds | Number of seconds. |
Int32 | milliseconds | Number of milliseconds. |
NpgsqlTimeSpan(Int32, Int32, Int64)
Initializes a new NpgsqlTimeSpan to the specified number of months, days & ticks.
Declaration
public NpgsqlTimeSpan(int months, int days, long ticks)
Parameters
Type | Name | Description |
---|---|---|
Int32 | months | Number of months. |
Int32 | days | Number of days. |
Int64 | ticks | Number of 100ns units. |
NpgsqlTimeSpan(Int64)
Initializes a new NpgsqlTimeSpan to the specified number of ticks.
Declaration
public NpgsqlTimeSpan(long ticks)
Parameters
Type | Name | Description |
---|---|---|
Int64 | ticks | A time period expressed in 100ns units. |
NpgsqlTimeSpan(TimeSpan)
Initializes a new NpgsqlTimeSpan to hold the same time as a TimeSpan
Declaration
public NpgsqlTimeSpan(TimeSpan timespan)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | timespan | A time period expressed in a TimeSpan |
Fields
DaysPerMonth
Represents the number of days assumed in one month if month justification or unjustifcation is performed. This is set to 30 for consistency with PostgreSQL. Note that this is means that month adjustments cause a year to be taken as 30 × 12 = 360 rather than 356/366 days.
Declaration
public const int DaysPerMonth = 30
Field Value
Type | Description |
---|---|
Int32 |
HoursPerDay
Represents the number of hours in one day (assuming no daylight savings adjustments). This field is constant.
Declaration
public const int HoursPerDay = 24
Field Value
Type | Description |
---|---|
Int32 |
MaxValue
Represents the maximum NpgsqlTimeSpan. This field is read-only.
Declaration
public static readonly NpgsqlTimeSpan MaxValue
Field Value
Type | Description |
---|---|
NpgsqlTimeSpan |
MinValue
Represents the minimum NpgsqlTimeSpan. This field is read-only.
Declaration
public static readonly NpgsqlTimeSpan MinValue
Field Value
Type | Description |
---|---|
NpgsqlTimeSpan |
MonthsPerYear
Represents the number of months in a year. This field is constant.
Declaration
public const int MonthsPerYear = 12
Field Value
Type | Description |
---|---|
Int32 |
TicksPerDay
Represents the number of ticks (100ns periods) in one day. This field is constant.
Declaration
public const long TicksPerDay = 864000000000L
Field Value
Type | Description |
---|---|
Int64 |
TicksPerHour
Represents the number of ticks (100ns periods) in one hour. This field is constant.
Declaration
public const long TicksPerHour = 36000000000L
Field Value
Type | Description |
---|---|
Int64 |
TicksPerMicrosecond
Represents the number of ticks (100ns periods) in one microsecond. This field is constant.
Declaration
public const long TicksPerMicrosecond = 10L
Field Value
Type | Description |
---|---|
Int64 |
TicksPerMillsecond
Represents the number of ticks (100ns periods) in one millisecond. This field is constant.
Declaration
public const long TicksPerMillsecond = 10000L
Field Value
Type | Description |
---|---|
Int64 |
TicksPerMinute
Represents the number of ticks (100ns periods) in one minute. This field is constant.
Declaration
public const long TicksPerMinute = 600000000L
Field Value
Type | Description |
---|---|
Int64 |
TicksPerMonth
Represents the number of ticks (100ns periods) in one day, assuming 30 days per month. DaysPerMonth
Declaration
public const long TicksPerMonth = 25920000000000L
Field Value
Type | Description |
---|---|
Int64 |
TicksPerSecond
Represents the number of ticks (100ns periods) in one second. This field is constant.
Declaration
public const long TicksPerSecond = 10000000L
Field Value
Type | Description |
---|---|
Int64 |
Zero
Represents the zero NpgsqlTimeSpan. This field is read-only.
Declaration
public static readonly NpgsqlTimeSpan Zero
Field Value
Type | Description |
---|---|
NpgsqlTimeSpan |
Properties
Days
Gets the number of days held in the instance.
Declaration
public readonly int Days { get; }
Property Value
Type | Description |
---|---|
Int32 |
Hours
Gets the number of whole hours held in the instance.
Declaration
public readonly int Hours { get; }
Property Value
Type | Description |
---|---|
Int32 |
Microseconds
Gets the number of whole microseconds held in the instance.
Declaration
public readonly int Microseconds { get; }
Property Value
Type | Description |
---|---|
Int32 |
Milliseconds
Gets the number of whole milliseconds held in the instance.
Declaration
public readonly int Milliseconds { get; }
Property Value
Type | Description |
---|---|
Int32 |
Minutes
Gets the number of whole minutes held in the instance.
Declaration
public readonly int Minutes { get; }
Property Value
Type | Description |
---|---|
Int32 |
Months
Gets the number of months held in the instance.
Declaration
public readonly int Months { get; }
Property Value
Type | Description |
---|---|
Int32 |
Seconds
Gets the number of whole seconds held in the instance.
Declaration
public readonly int Seconds { get; }
Property Value
Type | Description |
---|---|
Int32 |
Ticks
The total number of ticks(100ns units) contained. This is the resolution of the
NpgsqlTimeSpan type. This ignores the number of days and
months held. If you want them included use UnjustifyInterval() first.
As such, if the 100-nanosecond resolution is significant to an application, a PostgreSQL interval will
not suffice for those purposes. In more frequent cases though, the resolution of the interval suffices.
NpgsqlTimeSpan will always suffice to handle the resolution of any interval value, and upon
writing to the database, will be rounded to the resolution used.
Declaration
public readonly long Ticks { get; }
Property Value
Type | Description |
---|---|
Int64 |
Time
Returns a TimeSpan representing the time component of the instance.
Declaration
public readonly TimeSpan Time { get; }
Property Value
Type | Description |
---|---|
TimeSpan |
TotalDays
The total number of days in the instance, assuming 24 hours in each day and 30 days in a month.
Declaration
public readonly double TotalDays { get; }
Property Value
Type | Description |
---|---|
Double |
TotalHours
The total number of hours in the instance, assuming 24 hours in each day and 30 days in a month.
Declaration
public readonly double TotalHours { get; }
Property Value
Type | Description |
---|---|
Double |
TotalMicroseconds
The total number of microseconds in the instance, assuming 24 hours in each day and 30 days in a month.
Declaration
public readonly double TotalMicroseconds { get; }
Property Value
Type | Description |
---|---|
Double |
TotalMilliseconds
The total number of milliseconds in the instance, assuming 24 hours in each day and 30 days in a month.
Declaration
public readonly double TotalMilliseconds { get; }
Property Value
Type | Description |
---|---|
Double |
TotalMinutes
The total number of minutes in the instance, assuming 24 hours in each day and 30 days in a month.
Declaration
public readonly double TotalMinutes { get; }
Property Value
Type | Description |
---|---|
Double |
TotalMonths
The total number of months in the instance, assuming 24 hours in each day and 30 days in a month.
Declaration
public readonly double TotalMonths { get; }
Property Value
Type | Description |
---|---|
Double |
TotalSeconds
The total number of seconds in the instance, assuming 24 hours in each day and 30 days in a month.
Declaration
public readonly double TotalSeconds { get; }
Property Value
Type | Description |
---|---|
Double |
TotalTicks
The total number of ticks (100ns units) in the instance, assuming 24 hours in each day and 30 days in a month.
Declaration
public readonly long TotalTicks { get; }
Property Value
Type | Description |
---|---|
Int64 |
Methods
Add(in NpgsqlTimeSpan)
Adds another interval to this instance and returns the result.
Declaration
public readonly NpgsqlTimeSpan Add(in NpgsqlTimeSpan interval)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlTimeSpan | interval | An NpgsqlTimeSpan to add to this instance. |
Returns
Type | Description |
---|---|
NpgsqlTimeSpan | An NpgsqlTimeSpan whose values are the sums of the two instances. |
Canonicalize()
Produces a canonical NpgslInterval with 0 months and hours in the range of [-23, 23].
While the fact that for many purposes, two different NpgsqlTimeSpan instances could be considered
equivalent (e.g. one with 2days, 3hours and one with 1day 27hours) there are different possible canonical forms.
E.g. we could move all excess hours into days and all excess days into months and have the most readable form,
or we could move everything into the ticks and have the form that allows for the easiest arithmetic) the form
chosen has two important properties that make it the best choice.
First, it is closest two how
TimeSpan objects are most often represented. Second, it is compatible with results of many
PostgreSQL functions, particularly with age() and the results of subtracting one date, time or timestamp from
another.
Note that the results of casting a TimeSpan to NpgsqlTimeSpan is
canonicalised.
Declaration
public readonly NpgsqlTimeSpan Canonicalize()
Returns
Type | Description |
---|---|
NpgsqlTimeSpan | An NpgsqlTimeSpan based on this one, but with months converted to multiples of ±30days and with any hours outside of the range [-23, 23] converted into days. |
Compare(NpgsqlTimeSpan, NpgsqlTimeSpan)
Compares two NpgsqlTimeSpan instances.
Declaration
public static int Compare(NpgsqlTimeSpan x, NpgsqlTimeSpan y)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlTimeSpan | x | The first NpgsqlTimeSpan. |
NpgsqlTimeSpan | y | The second NpgsqlTimeSpan. |
Returns
Type | Description |
---|---|
Int32 | 0 if the two are equal or equivalent. A value greater than zero if x is greater than y, a value less than zero if x is less than y. |
CompareTo(NpgsqlTimeSpan)
Compares this instance with another/
Declaration
public readonly int CompareTo(NpgsqlTimeSpan other)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlTimeSpan | other | An NpgsqlTimeSpan to compare this with. |
Returns
Type | Description |
---|---|
Int32 | 0 if the instances are equal or equivalent. A value less than zero if this instance is less than the argument. A value greater than zero if this instance is greater than the instance. |
CompareTo(Object)
Compares this instance with another/
Declaration
public readonly int CompareTo(object other)
Parameters
Type | Name | Description |
---|---|---|
Object | other | An object to compare this with. |
Returns
Type | Description |
---|---|
Int32 | 0 if the argument is an NpgsqlTimeSpan and the instances are equal or equivalent. A value less than zero if the argument is an NpgsqlTimeSpan and this instance is less than the argument. A value greater than zero if the argument is an NpgsqlTimeSpan and this instance is greater than the instance. |
Exceptions
Type | Condition |
---|---|
ArgumentException | The argument is not an NpgsqlTimeSpan. |
Duration()
This absolute value of this instance. In the case of some, but not all, components being negative, the rules used for justification are used to determine if the instance is positive or negative.
Declaration
public readonly NpgsqlTimeSpan Duration()
Returns
Type | Description |
---|---|
NpgsqlTimeSpan | An NpgsqlTimeSpan whose value is the absolute value of this instance. |
Equals(NpgsqlTimeSpan)
Returns true if another NpgsqlTimeSpan is exactly the same as this instance.
Declaration
public readonly bool Equals(NpgsqlTimeSpan other)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlTimeSpan | other | An NpgsqlTimeSpan for comparison. |
Returns
Type | Description |
---|---|
Boolean | true if the two NpgsqlTimeSpan instances are exactly the same, false otherwise. |
Equals(Object)
Returns true if another object is an NpgsqlTimeSpan, that is exactly the same as this instance
Declaration
public override readonly bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
Object | obj | An Object for comparison. |
Returns
Type | Description |
---|---|
Boolean | true if the argument is an NpgsqlTimeSpan and is exactly the same as this one, false otherwise. |
Overrides
FromDays(Double)
Creates an NpgsqlTimeSpan from a number of days.
Declaration
public static NpgsqlTimeSpan FromDays(double days)
Parameters
Type | Name | Description |
---|---|---|
Double | days | The number of days in the interval. |
Returns
Type | Description |
---|---|
NpgsqlTimeSpan | A Canonicalize()d NpgsqlTimeSpan with the given number of days. |
FromHours(Double)
Creates an NpgsqlTimeSpan from a number of hours.
Declaration
public static NpgsqlTimeSpan FromHours(double hours)
Parameters
Type | Name | Description |
---|---|---|
Double | hours | The number of hours in the interval. |
Returns
Type | Description |
---|---|
NpgsqlTimeSpan | A Canonicalize()d NpgsqlTimeSpan with the given number of hours. |
FromMicroseconds(Double)
Creates an NpgsqlTimeSpan from a number of microseconds.
Declaration
public static NpgsqlTimeSpan FromMicroseconds(double micro)
Parameters
Type | Name | Description |
---|---|---|
Double | micro | The number of microseconds in the interval. |
Returns
Type | Description |
---|---|
NpgsqlTimeSpan | A Canonicalize()d NpgsqlTimeSpan with the given number of microseconds. |
FromMilliseconds(Double)
Creates an NpgsqlTimeSpan from a number of milliseconds.
Declaration
public static NpgsqlTimeSpan FromMilliseconds(double milli)
Parameters
Type | Name | Description |
---|---|---|
Double | milli | The number of milliseconds in the interval. |
Returns
Type | Description |
---|---|
NpgsqlTimeSpan | A Canonicalize()d NpgsqlTimeSpan with the given number of milliseconds. |
FromMinutes(Double)
Creates an NpgsqlTimeSpan from a number of minutes.
Declaration
public static NpgsqlTimeSpan FromMinutes(double minutes)
Parameters
Type | Name | Description |
---|---|---|
Double | minutes | The number of minutes in the interval. |
Returns
Type | Description |
---|---|
NpgsqlTimeSpan | A Canonicalize()d NpgsqlTimeSpan with the given number of minutes. |
FromMonths(Double)
Creates an NpgsqlTimeSpan from a number of months.
Declaration
public static NpgsqlTimeSpan FromMonths(double months)
Parameters
Type | Name | Description |
---|---|---|
Double | months | The number of months in the interval. |
Returns
Type | Description |
---|---|
NpgsqlTimeSpan | A Canonicalize()d NpgsqlTimeSpan with the given number of months. |
FromSeconds(Double)
Creates an NpgsqlTimeSpan from a number of seconds.
Declaration
public static NpgsqlTimeSpan FromSeconds(double seconds)
Parameters
Type | Name | Description |
---|---|---|
Double | seconds | The number of seconds in the interval. |
Returns
Type | Description |
---|---|
NpgsqlTimeSpan | A Canonicalize()d NpgsqlTimeSpan with the given number of seconds. |
FromTicks(Int64)
Creates an NpgsqlTimeSpan from a number of ticks.
Declaration
public static NpgsqlTimeSpan FromTicks(long ticks)
Parameters
Type | Name | Description |
---|---|---|
Int64 | ticks | The number of ticks (100ns units) in the interval. |
Returns
Type | Description |
---|---|
NpgsqlTimeSpan | A Canonicalize()d NpgsqlTimeSpan with the given number of ticks. |
GetHashCode()
A hash code suitable for uses with hashing algorithms.
Declaration
public override readonly int GetHashCode()
Returns
Type | Description |
---|---|
Int32 | An signed integer. |
Overrides
JustifyDays()
Equivalent to PostgreSQL's justify_days function.
Declaration
public readonly NpgsqlTimeSpan JustifyDays()
Returns
Type | Description |
---|---|
NpgsqlTimeSpan | An NpgsqlTimeSpan based on this one, but with any hours outside of the range [-23, 23] converted into days. |
JustifyInterval()
Equivalent to PostgreSQL's justify_interval function.
Declaration
public readonly NpgsqlTimeSpan JustifyInterval()
Returns
Type | Description |
---|---|
NpgsqlTimeSpan | An NpgsqlTimeSpan based on this one, but with any months converted to multiples of ±30days and then with any days converted to multiples of ±24hours |
JustifyMonths()
Equivalent to PostgreSQL's justify_months function.
Declaration
public readonly NpgsqlTimeSpan JustifyMonths()
Returns
Type | Description |
---|---|
NpgsqlTimeSpan | An NpgsqlTimeSpan based on this one, but with any days outside of the range [-30, 30] converted into months. |
Negate()
Returns an NpgsqlTimeSpan whose value is the negated value of this instance.
Declaration
public readonly NpgsqlTimeSpan Negate()
Returns
Type | Description |
---|---|
NpgsqlTimeSpan | An NpgsqlTimeSpan whose value is the negated value of this instance. |
Parse(String)
Parses a String and returns a NpgsqlTimeSpan instance. Designed to use the formats generally returned by PostgreSQL.
Declaration
public static NpgsqlTimeSpan Parse(string str)
Parameters
Type | Name | Description |
---|---|---|
String | str | The String to parse. |
Returns
Type | Description |
---|---|
NpgsqlTimeSpan | An NpgsqlTimeSpan represented by the argument. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | The string was null. |
OverflowException | A value obtained from parsing the string exceeded the values allowed for the relevant component. |
FormatException | The string was not in a format that could be parsed to produce an NpgsqlTimeSpan. |
Plus(in NpgsqlTimeSpan)
Returns the instance.
Declaration
public static NpgsqlTimeSpan Plus(in NpgsqlTimeSpan x)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlTimeSpan | x |
Returns
Type | Description |
---|---|
NpgsqlTimeSpan |
Subtract(in NpgsqlTimeSpan)
Subtracts another interval from this instance and returns the result.
Declaration
public readonly NpgsqlTimeSpan Subtract(in NpgsqlTimeSpan interval)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlTimeSpan | interval | An NpgsqlTimeSpan to subtract from this instance. |
Returns
Type | Description |
---|---|
NpgsqlTimeSpan | An NpgsqlTimeSpan whose values are the differences of the two instances. |
ToNpgsqlTimeSpan(TimeSpan)
Casts a TimeSpan to an NpgsqlTimeSpan.
Declaration
public static NpgsqlTimeSpan ToNpgsqlTimeSpan(TimeSpan timespan)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | timespan |
Returns
Type | Description |
---|---|
NpgsqlTimeSpan |
ToString()
Create a String representation of the NpgsqlTimeSpan instance.
The format returned is of the form:
[M mon[s]] [d day[s]] [HH:mm:ss[.f[f[f[f[f[f[f[f[f]]]]]]]]]]
A zero NpgsqlTimeSpan is represented as 00:00:00
Declaration
public override readonly string ToString()
Returns
Type | Description |
---|---|
String | The String representation. |
Overrides
ToTimeSpan(in NpgsqlTimeSpan)
Casts an NpgsqlTimeSpan to a TimeSpan.
Declaration
public static TimeSpan ToTimeSpan(in NpgsqlTimeSpan interval)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlTimeSpan | interval |
Returns
Type | Description |
---|---|
TimeSpan |
TryParse(String, out NpgsqlTimeSpan)
Attempt to parse a String to produce an NpgsqlTimeSpan.
Declaration
public static bool TryParse(string str, out NpgsqlTimeSpan result)
Parameters
Type | Name | Description |
---|---|---|
String | str | The String to parse. |
NpgsqlTimeSpan | result | (out) The NpgsqlTimeSpan produced, or Zero if the parsing failed. |
Returns
Type | Description |
---|---|
Boolean | true if the parsing succeeded, false otherwise. |
UnjustifyDays()
Opposite to PostgreSQL's justify_days function.
Declaration
public readonly NpgsqlTimeSpan UnjustifyDays()
Returns
Type | Description |
---|---|
NpgsqlTimeSpan | An NpgsqlTimeSpan based on this one, but with any days converted to multiples of ±24hours. |
UnjustifyInterval()
Opposite to PostgreSQL's justify_interval function.
Declaration
public readonly NpgsqlTimeSpan UnjustifyInterval()
Returns
Type | Description |
---|---|
NpgsqlTimeSpan | An NpgsqlTimeSpan based on this one, but with any months converted to multiples of ±30days and then any days converted to multiples of ±24hours; |
UnjustifyMonths()
Opposite to PostgreSQL's justify_months function.
Declaration
public readonly NpgsqlTimeSpan UnjustifyMonths()
Returns
Type | Description |
---|---|
NpgsqlTimeSpan | An NpgsqlTimeSpan based on this one, but with any months converted to multiples of ±30days. |
Operators
Addition(NpgsqlTimeSpan, NpgsqlTimeSpan)
Adds two NpgsqlTimeSpan together.
Declaration
public static NpgsqlTimeSpan operator +(NpgsqlTimeSpan x, NpgsqlTimeSpan y)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlTimeSpan | x | The first NpgsqlTimeSpan to add. |
NpgsqlTimeSpan | y | The second NpgsqlTimeSpan to add. |
Returns
Type | Description |
---|---|
NpgsqlTimeSpan | An NpgsqlTimeSpan whose values are the sum of the arguments. |
Equality(NpgsqlTimeSpan, NpgsqlTimeSpan)
Returns true if two NpgsqlTimeSpan are exactly the same.
Declaration
public static bool operator ==(NpgsqlTimeSpan x, NpgsqlTimeSpan y)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlTimeSpan | x | The first NpgsqlTimeSpan to compare. |
NpgsqlTimeSpan | y | The second NpgsqlTimeSpan to compare. |
Returns
Type | Description |
---|---|
Boolean | true if the two arguments are exactly the same, false otherwise. |
Explicit(NpgsqlTimeSpan to TimeSpan)
Explicit cast of an NpgsqlTimeSpan to a TimeSpan.
Declaration
public static explicit operator TimeSpan(NpgsqlTimeSpan interval)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlTimeSpan | interval |
Returns
Type | Description |
---|---|
TimeSpan | An equivalent TimeSpan. |
GreaterThan(NpgsqlTimeSpan, NpgsqlTimeSpan)
Compares two NpgsqlTimeSpan instances to see if the first is greater than the second
Declaration
public static bool operator>(NpgsqlTimeSpan x, NpgsqlTimeSpan y)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlTimeSpan | x | The first NpgsqlTimeSpan to compare. |
NpgsqlTimeSpan | y | The second NpgsqlTimeSpan to compare. |
Returns
Type | Description |
---|---|
Boolean | true if the first NpgsqlTimeSpan is greater than second, false otherwise. |
GreaterThanOrEqual(NpgsqlTimeSpan, NpgsqlTimeSpan)
Compares two NpgsqlTimeSpan instances to see if the first is greater than or equivalent the second
Declaration
public static bool operator >=(NpgsqlTimeSpan x, NpgsqlTimeSpan y)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlTimeSpan | x | The first NpgsqlTimeSpan to compare. |
NpgsqlTimeSpan | y | The second NpgsqlTimeSpan to compare. |
Returns
Type | Description |
---|---|
Boolean | true if the first NpgsqlTimeSpan is greater than or equivalent to the second, false otherwise. |
Implicit(TimeSpan to NpgsqlTimeSpan)
Implicit cast of a TimeSpan to an NpgsqlTimeSpan
Declaration
public static implicit operator NpgsqlTimeSpan(TimeSpan timespan)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | timespan | A TimeSpan |
Returns
Type | Description |
---|---|
NpgsqlTimeSpan | An eqivalent, canonical, NpgsqlTimeSpan. |
Inequality(NpgsqlTimeSpan, NpgsqlTimeSpan)
Returns false if two NpgsqlTimeSpan are exactly the same.
Declaration
public static bool operator !=(NpgsqlTimeSpan x, NpgsqlTimeSpan y)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlTimeSpan | x | The first NpgsqlTimeSpan to compare. |
NpgsqlTimeSpan | y | The second NpgsqlTimeSpan to compare. |
Returns
Type | Description |
---|---|
Boolean | false if the two arguments are exactly the same, true otherwise. |
LessThan(NpgsqlTimeSpan, NpgsqlTimeSpan)
Compares two NpgsqlTimeSpan instances to see if the first is less than the second
Declaration
public static bool operator <(NpgsqlTimeSpan x, NpgsqlTimeSpan y)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlTimeSpan | x | The first NpgsqlTimeSpan to compare. |
NpgsqlTimeSpan | y | The second NpgsqlTimeSpan to compare. |
Returns
Type | Description |
---|---|
Boolean | true if the first NpgsqlTimeSpan is less than second, false otherwise. |
LessThanOrEqual(NpgsqlTimeSpan, NpgsqlTimeSpan)
Compares two NpgsqlTimeSpan instances to see if the first is less than or equivalent to the second
Declaration
public static bool operator <=(NpgsqlTimeSpan x, NpgsqlTimeSpan y)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlTimeSpan | x | The first NpgsqlTimeSpan to compare. |
NpgsqlTimeSpan | y | The second NpgsqlTimeSpan to compare. |
Returns
Type | Description |
---|---|
Boolean | true if the first NpgsqlTimeSpan is less than or equivalent to second, false otherwise. |
Subtraction(NpgsqlTimeSpan, NpgsqlTimeSpan)
Subtracts one NpgsqlTimeSpan from another.
Declaration
public static NpgsqlTimeSpan operator -(NpgsqlTimeSpan x, NpgsqlTimeSpan y)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlTimeSpan | x | The NpgsqlTimeSpan to subtract the other from. |
NpgsqlTimeSpan | y | The NpgsqlTimeSpan to subtract from the other. |
Returns
Type | Description |
---|---|
NpgsqlTimeSpan | An NpgsqlTimeSpan whose values are the difference of the arguments |
UnaryNegation(NpgsqlTimeSpan)
Negates an NpgsqlTimeSpan instance.
Declaration
public static NpgsqlTimeSpan operator -(NpgsqlTimeSpan x)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlTimeSpan | x | An NpgsqlTimeSpan. |
Returns
Type | Description |
---|---|
NpgsqlTimeSpan | The negation of the argument. |
UnaryPlus(NpgsqlTimeSpan)
Returns the instance.
Declaration
public static NpgsqlTimeSpan operator +(NpgsqlTimeSpan x)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlTimeSpan | x |
Returns
Type | Description |
---|---|
NpgsqlTimeSpan |
Explicit Interface Implementations
IComparer<NpgsqlTimeSpan>.Compare(NpgsqlTimeSpan, NpgsqlTimeSpan)
Declaration
readonly int IComparer<NpgsqlTimeSpan>.Compare(NpgsqlTimeSpan x, NpgsqlTimeSpan y)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlTimeSpan | x | |
NpgsqlTimeSpan | y |
Returns
Type | Description |
---|---|
Int32 |
IComparer.Compare(Object, Object)
Declaration
readonly int IComparer.Compare(object x, object y)
Parameters
Type | Name | Description |
---|---|---|
Object | x | |
Object | y |
Returns
Type | Description |
---|---|
Int32 |