Show / Hide Table of Contents

Class TimeRange

Represents a range of time from First to Last. First and Last are both considered to be included in the range. The legal range of values is from the unix epoch, midnight 1/1/1970, to DateTime.MaxValue.

Inheritance
object
TimeRange
Inherited Members
object.Equals(object, object)
object.GetType()
object.ReferenceEquals(object, object)
Namespace: Cognite.Extractor.Common
Assembly: Cognite.Common.dll
Syntax
public sealed class TimeRange

Constructors

| Edit this page View Source

TimeRange(DateTime, DateTime)

Initialize a TimeRange object from two timestamps.

Declaration
public TimeRange(DateTime first, DateTime last)
Parameters
Type Name Description
DateTime first

First point in the time range

DateTime last

Last point in the time range

Fields

| Edit this page View Source

Complete

The largest legal range, (Epoch, DateTime.MaxValue). Extending a complete range will return the complete range. Contracting a complete range will return the given range.

Declaration
public static readonly TimeRange Complete
Field Value
Type Description
TimeRange
| Edit this page View Source

Empty

An empty range where first > last, and both are at the extreme range, (DateTime.MaxValue, Epoch). Extending an empty range will return the given range Contracting an empty range will return the empty range

Declaration
public static readonly TimeRange Empty
Field Value
Type Description
TimeRange

Properties

| Edit this page View Source

First

First point in the range

Declaration
public DateTime First { get; }
Property Value
Type Description
DateTime
| Edit this page View Source

IsEmpty

True if there are no points in the range at all (first > last).

Declaration
public bool IsEmpty { get; }
Property Value
Type Description
bool
| Edit this page View Source

Last

Last point in the range

Declaration
public DateTime Last { get; }
Property Value
Type Description
DateTime

Methods

| Edit this page View Source

After(DateTime)

Check if t is after the last point in the range.

Declaration
public bool After(DateTime t)
Parameters
Type Name Description
DateTime t

Datetime to test

Returns
Type Description
bool

True if t is after the last point in the range

| Edit this page View Source

Before(DateTime)

Check if t is before the first point in the range.

Declaration
public bool Before(DateTime t)
Parameters
Type Name Description
DateTime t

Datetime to test

Returns
Type Description
bool

True if t is before the first point in the range

| Edit this page View Source

Contains(DateTime)

True if given datetime is inside the range

Declaration
public bool Contains(DateTime t)
Parameters
Type Name Description
DateTime t

DateTime to test

Returns
Type Description
bool
| Edit this page View Source

Contract(TimeRange)

Returns a new TimeRange contracted by the given TimeRange New TimeRange is the latest start point and the earliest end point.

Declaration
public TimeRange Contract(TimeRange newRange)
Parameters
Type Name Description
TimeRange newRange

Extending range

Returns
Type Description
TimeRange

A new TimeRange contracted by newRange

| Edit this page View Source

Contract(DateTime?, DateTime?)

Return a new TimeRange contracted by the given timestamps. New TimeRange is the latest start point and earliest end point. Letting first or last be null will keep the existing value for that end of the range.

Declaration
public TimeRange Contract(DateTime? first, DateTime? last)
Parameters
Type Name Description
DateTime? first

First point in contracting range

DateTime? last

Last point in contracting range

Returns
Type Description
TimeRange

A new TimeRange contracted by first and last

| Edit this page View Source

Equals(object?)

Compares this time range with the provided object and returns true if they are equal

Declaration
public override bool Equals(object? obj)
Parameters
Type Name Description
object obj

Object to compare

Returns
Type Description
bool

true, if equal. false otherwise

Overrides
object.Equals(object)
| Edit this page View Source

Extend(TimeRange)

Returns a new TimeRange extended by the given TimeRange New TimeRange is the earliest start point and the latest end point.

Declaration
public TimeRange Extend(TimeRange newRange)
Parameters
Type Name Description
TimeRange newRange

Extending range

Returns
Type Description
TimeRange

A new TimeRange extended by newRange

| Edit this page View Source

Extend(DateTime?, DateTime?)

Return a new TimeRange extended by the given timestamps. New TimeRange is the earliest start point and the latest end point. Letting first or last be null will keep the existing value for that end of the range.

Declaration
public TimeRange Extend(DateTime? first, DateTime? last)
Parameters
Type Name Description
DateTime? first

First point in extending range

DateTime? last

Last point in extending range

Returns
Type Description
TimeRange

A new TimeRange extended by first and last

| Edit this page View Source

GetHashCode()

Returns the computed hash code for this time range using its (First, Last) tuple

Declaration
public override int GetHashCode()
Returns
Type Description
int
Overrides
object.GetHashCode()
| Edit this page View Source

ToString()

Returns a string representation of the TimeRange, on the form ([First as ISO-string], [Last as ISO-string]).

Declaration
public override string ToString()
Returns
Type Description
string

A string representation of the TimeRange

Overrides
object.ToString()

Operators

| Edit this page View Source

operator ==(TimeRange, TimeRange)

Returns true if the provided time ranges are equal

Declaration
public static bool operator ==(TimeRange x, TimeRange y)
Parameters
Type Name Description
TimeRange x

time range

TimeRange y

time range

Returns
Type Description
bool

true, if equal. false otherwise

| Edit this page View Source

operator !=(TimeRange, TimeRange)

Returns true if the provided time ranges are different

Declaration
public static bool operator !=(TimeRange x, TimeRange y)
Parameters
Type Name Description
TimeRange x

time range

TimeRange y

time range

Returns
Type Description
bool

true, if different. false otherwise

Extension Methods

DataModelUtils.GetOrCreateResourcesAsync<T, T2>(T2, IEnumerable<InstanceIdentifier>, Func<IEnumerable<InstanceIdentifier>, IEnumerable<SourcedNodeWrite<T>>>, Func<IEnumerable<SourcedNodeWrite<T>>, SanitationMode, (IEnumerable<SourcedNodeWrite<T>>, IEnumerable<CogniteError<SourcedNodeWrite<T>>>)>, int, int, RetryMode, SanitationMode, CancellationToken)
  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX