Show / Hide Table of Contents

Struct NpgsqlTimeSpan

Represents the PostgreSQL interval datatype.

Implements
System.IComparable
System.Collections.IComparer
System.IEquatable<NpgsqlTimeSpan>
System.IComparable<NpgsqlTimeSpan>
System.Collections.Generic.IComparer<NpgsqlTimeSpan>
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetType()
Namespace: NpgsqlTypes
Assembly: Npgsql.dll
Syntax
[Serializable]
public 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 System.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 System.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 System.TimeSpan.

If you don't know whether these differences are important to your application, they probably arent! Just use System.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 System.Data.IDataRecord.GetValue(System.Int32) on a field containing an NpgsqlTimeSpan value will return a System.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
System.Int32 days

Number of days.

System.Int32 hours

Number of hours.

System.Int32 minutes

Number of minutes.

System.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
System.Int32 days

Number of days.

System.Int32 hours

Number of hours.

System.Int32 minutes

Number of minutes.

System.Int32 seconds

Number of seconds.

System.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
System.Int32 months

Number of months.

System.Int32 days

Number of days.

System.Int32 hours

Number of hours.

System.Int32 minutes

Number of minutes.

System.Int32 seconds

Number of seconds.

System.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
System.Int32 years

Number of years.

System.Int32 months

Number of months.

System.Int32 days

Number of days.

System.Int32 hours

Number of hours.

System.Int32 minutes

Number of minutes.

System.Int32 seconds

Number of seconds.

System.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
System.Int32 months

Number of months.

System.Int32 days

Number of days.

System.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
System.Int64 ticks

A time period expressed in 100ns units.

NpgsqlTimeSpan(TimeSpan)

Initializes a new NpgsqlTimeSpan to hold the same time as a System.TimeSpan

Declaration
public NpgsqlTimeSpan(TimeSpan timespan)
Parameters
Type Name Description
System.TimeSpan timespan

A time period expressed in a System.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
System.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
System.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
System.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
System.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
System.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
System.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
System.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
System.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
System.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
System.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. Note that this does not pay attention to a time component with -24 or less hours or 24 or more hours, unless JustifyDays() has been called to produce this instance.

Declaration
public int Days { get; }
Property Value
Type Description
System.Int32

Hours

Gets the number of whole hours held in the instance. Note that this can be less than -23 or greater than 23 unless JustifyDays() has been used to produce this instance.

Declaration
public int Hours { get; }
Property Value
Type Description
System.Int32

Microseconds

Gets the number of whole microseconds held in the instance. An in the range [-999999, 999999].

Declaration
public int Microseconds { get; }
Property Value
Type Description
System.Int32

Milliseconds

Gets the number of whole milliseconds held in the instance. An in the range [-999, 999].

Declaration
public int Milliseconds { get; }
Property Value
Type Description
System.Int32

Minutes

Gets the number of whole minutes held in the instance. An in the range [-59, 59].

Declaration
public int Minutes { get; }
Property Value
Type Description
System.Int32

Months

Gets the number of months held in the instance. Note that this does not pay attention to a day component with -30 or less days or 30 or more days, unless JustifyMonths() has been called to produce this instance.

Declaration
public int Months { get; }
Property Value
Type Description
System.Int32

Seconds

Gets the number of whole seconds held in the instance. An in the range [-59, 59].

Declaration
public int Seconds { get; }
Property Value
Type Description
System.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. The resolution of the PostgreSQL interval type is by default 1µs = 1,000 ns. It may be smaller as follows:

  1. interval(0)resolution of 1s (1 second)
  2. interval(1)resolution of 100ms = 0.1s (100 milliseconds)
  3. interval(2)resolution of 10ms = 0.01s (10 milliseconds)
  4. interval(3)resolution of 1ms = 0.001s (1 millisecond)
  5. interval(4)resolution of 100µs = 0.0001s (100 microseconds)
  6. interval(5)resolution of 10µs = 0.00001s (10 microseconds)
  7. interval(6) or intervalresolution of 1µs = 0.000001s (1 microsecond)

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.

The number of ticks in the instance.
Declaration
public long Ticks { get; }
Property Value
Type Description
System.Int64

Time

Returns a System.TimeSpan representing the time component of the instance. Note that this may have a value beyond the range ±23:59:59.9999999 unless JustifyDays() has been called to produce this instance.

Declaration
public TimeSpan Time { get; }
Property Value
Type Description
System.TimeSpan

TotalDays

The total number of days in the instance, assuming 24 hours in each day and 30 days in a month.

Declaration
public double TotalDays { get; }
Property Value
Type Description
System.Double

TotalHours

The total number of hours in the instance, assuming 24 hours in each day and 30 days in a month.

Declaration
public double TotalHours { get; }
Property Value
Type Description
System.Double

TotalMicroseconds

The total number of microseconds in the instance, assuming 24 hours in each day and 30 days in a month.

Declaration
public double TotalMicroseconds { get; }
Property Value
Type Description
System.Double

TotalMilliseconds

The total number of milliseconds in the instance, assuming 24 hours in each day and 30 days in a month.

Declaration
public double TotalMilliseconds { get; }
Property Value
Type Description
System.Double

TotalMinutes

The total number of minutes in the instance, assuming 24 hours in each day and 30 days in a month.

Declaration
public double TotalMinutes { get; }
Property Value
Type Description
System.Double

TotalMonths

The total number of months in the instance, assuming 24 hours in each day and 30 days in a month.

Declaration
public double TotalMonths { get; }
Property Value
Type Description
System.Double

TotalSeconds

The total number of seconds in the instance, assuming 24 hours in each day and 30 days in a month.

Declaration
public double TotalSeconds { get; }
Property Value
Type Description
System.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 long TotalTicks { get; }
Property Value
Type Description
System.Int64

Methods

Add(NpgsqlTimeSpan)

Adds another interval to this instance and returns the result.

Declaration
public NpgsqlTimeSpan Add(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 System.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 System.TimeSpan to NpgsqlTimeSpan is canonicalised.

Declaration
public 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
System.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 int CompareTo(NpgsqlTimeSpan other)
Parameters
Type Name Description
NpgsqlTimeSpan other

An NpgsqlTimeSpan to compare this with.

Returns
Type Description
System.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 int CompareTo(object other)
Parameters
Type Name Description
System.Object other

An object to compare this with.

Returns
Type Description
System.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
System.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 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 bool Equals(NpgsqlTimeSpan other)
Parameters
Type Name Description
NpgsqlTimeSpan other

An NpgsqlTimeSpan for comparison.

Returns
Type Description
System.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 bool Equals(object obj)
Parameters
Type Name Description
System.Object obj

An System.Object for comparison.

Returns
Type Description
System.Boolean

true if the argument is an NpgsqlTimeSpan and is exactly the same as this one, false otherwise.

Overrides
System.ValueType.Equals(System.Object)

FromDays(Double)

Creates an NpgsqlTimeSpan from a number of days.

Declaration
public static NpgsqlTimeSpan FromDays(double days)
Parameters
Type Name Description
System.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
System.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
System.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
System.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
System.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
System.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
System.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
System.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 int GetHashCode()
Returns
Type Description
System.Int32

An signed integer.

Overrides
System.ValueType.GetHashCode()

JustifyDays()

Equivalent to PostgreSQL's justify_days function.

Declaration
public 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 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 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 NpgsqlTimeSpan Negate()
Returns
Type Description
NpgsqlTimeSpan

An NpgsqlTimeSpan whose value is the negated value of this instance.

Parse(String)

Parses a System.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
System.String str

The System.String to parse.

Returns
Type Description
NpgsqlTimeSpan

An NpgsqlTimeSpan represented by the argument.

Exceptions
Type Condition
System.ArgumentNullException

The string was null.

System.OverflowException

A value obtained from parsing the string exceeded the values allowed for the relevant component.

System.FormatException

The string was not in a format that could be parsed to produce an NpgsqlTimeSpan.

Plus(NpgsqlTimeSpan)

Returns the instance.

Declaration
public static NpgsqlTimeSpan Plus(NpgsqlTimeSpan x)
Parameters
Type Name Description
NpgsqlTimeSpan x
Returns
Type Description
NpgsqlTimeSpan

Subtract(NpgsqlTimeSpan)

Subtracts another interval from this instance and returns the result.

Declaration
public NpgsqlTimeSpan Subtract(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 System.TimeSpan to an NpgsqlTimeSpan.

Declaration
public static NpgsqlTimeSpan ToNpgsqlTimeSpan(TimeSpan timespan)
Parameters
Type Name Description
System.TimeSpan timespan
Returns
Type Description
NpgsqlTimeSpan

ToString()

Create a System.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 Ticks are 100ns, Postgress resolution is only to 1µs at most. Hence we lose 1 or more decimal precision in storing values in the database. Despite this, this method will output that extra digit of precision. It's forward-compatible with any future increases in resolution up to 100ns, and also makes this ToString() more applicable to any other use-case.

Declaration
public override string ToString()
Returns
Type Description
System.String

The System.String representation.

Overrides
System.ValueType.ToString()

ToTimeSpan(NpgsqlTimeSpan)

Casts an NpgsqlTimeSpan to a System.TimeSpan.

Declaration
public static TimeSpan ToTimeSpan(NpgsqlTimeSpan interval)
Parameters
Type Name Description
NpgsqlTimeSpan interval
Returns
Type Description
System.TimeSpan

TryParse(String, out NpgsqlTimeSpan)

Attempt to parse a System.String to produce an NpgsqlTimeSpan.

Declaration
public static bool TryParse(string str, out NpgsqlTimeSpan result)
Parameters
Type Name Description
System.String str

The System.String to parse.

NpgsqlTimeSpan result

(out) The NpgsqlTimeSpan produced, or Zero if the parsing failed.

Returns
Type Description
System.Boolean

true if the parsing succeeded, false otherwise.

UnjustifyDays()

Opposite to PostgreSQL's justify_days function.

Declaration
public 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 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 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
System.Boolean

true if the two arguments are exactly the same, false otherwise.

Explicit(NpgsqlTimeSpan to TimeSpan)

Explicit cast of an NpgsqlTimeSpan to a System.TimeSpan.

Declaration
public static explicit operator TimeSpan(NpgsqlTimeSpan interval)
Parameters
Type Name Description
NpgsqlTimeSpan interval

A NpgsqlTimeSpan.

Returns
Type Description
System.TimeSpan

An equivalent System.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
System.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
System.Boolean

true if the first NpgsqlTimeSpan is greater than or equivalent to the second, false otherwise.

Implicit(TimeSpan to NpgsqlTimeSpan)

Implicit cast of a System.TimeSpan to an NpgsqlTimeSpan

Declaration
public static implicit operator NpgsqlTimeSpan(TimeSpan timespan)
Parameters
Type Name Description
System.TimeSpan timespan

A System.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
System.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
System.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
System.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
int IComparer<NpgsqlTimeSpan>.Compare(NpgsqlTimeSpan x, NpgsqlTimeSpan y)
Parameters
Type Name Description
NpgsqlTimeSpan x
NpgsqlTimeSpan y
Returns
Type Description
System.Int32

IComparer.Compare(Object, Object)

Declaration
int IComparer.Compare(object x, object y)
Parameters
Type Name Description
System.Object x
System.Object y
Returns
Type Description
System.Int32

Implements

System.IComparable
System.Collections.IComparer
System.IEquatable<T>
System.IComparable<T>
System.Collections.Generic.IComparer<T>

See Also

Ticks
JustifyDays()
JustifyMonths()
Canonicalize()
Back to top Generated by DocFX