Table of Contents

Class CoordinatedUniversalTime

Namespace
Codebelt.SharedKernel
Assembly
Codebelt.SharedKernel.dll

Represents a CoordinatedUniversalTime (UTC) object that can be used when you need a timestamp that is based on an absolute time.

public record CoordinatedUniversalTime : ComparableValueObject<DateTime>, IEquatable<ValueObject>, IEquatable<SingleValueObject<DateTime>>, IComparisonOperators<ComparableValueObject<DateTime>, ComparableValueObject<DateTime>, bool>, IEqualityOperators<ComparableValueObject<DateTime>, ComparableValueObject<DateTime>, bool>, IEquatable<ComparableValueObject<DateTime>>, IEquatable<CoordinatedUniversalTime>
Inheritance
object
CoordinatedUniversalTime
Implements
Inherited Members
SingleValueObject<DateTime>.GetHashCode()
SingleValueObject<DateTime>.Equals(object)
SingleValueObject<DateTime>.Equals(ValueObject)
SingleValueObject<DateTime>.Equals(SingleValueObject<DateTime>)
SingleValueObject<DateTime>.<Clone>$()
SingleValueObject<DateTime>.EqualityContract

Remarks

Constructors

CoordinatedUniversalTime(DateTime)

Initializes a new instance of the CoordinatedUniversalTime class.

public CoordinatedUniversalTime(DateTime value)

Parameters

value DateTime

The DateTime value to assign the role of CoordinatedUniversalTime.

Exceptions

ArgumentException

value is not in a valid state, e.g., it's different from Utc.

Fields

MaxValue

Denotes the largest possible value of CoordinatedUniversalTime.

public static readonly CoordinatedUniversalTime MaxValue

Field Value

CoordinatedUniversalTime

MinValue

Denotes the smallest possible value of CoordinatedUniversalTime.

public static readonly CoordinatedUniversalTime MinValue

Field Value

CoordinatedUniversalTime

Methods

FromString(string)

Converts the string representation of a date and time to its CoordinatedUniversalTime> equivalent.

public static CoordinatedUniversalTime FromString(string value)

Parameters

value string

A string that contains a date and time to convert.

Returns

CoordinatedUniversalTime

A new instance of CoordinatedUniversalTime that represents value.

Now()

Returns a CoordinatedUniversalTime whose value is the current UTC date and time.

public static CoordinatedUniversalTime Now()

Returns

CoordinatedUniversalTime

A new instance of CoordinatedUniversalTime set to the current date and time on this computer.

ToString()

Returns a string> that represents this instance and complies with ISO 8601.

public override string ToString()

Returns

string

A string> that represents this instance and complies with ISO 8601.

Operators

implicit operator DateTime(CoordinatedUniversalTime)

Performs an implicit conversion from CoordinatedUniversalTime to DateTime.

public static implicit operator DateTime(CoordinatedUniversalTime value)

Parameters

value CoordinatedUniversalTime

The value to convert.

Returns

DateTime

A DateTime that is equivalent to value.

implicit operator CoordinatedUniversalTime(DateTime)

Performs an implicit conversion from DateTime to CoordinatedUniversalTime.

public static implicit operator CoordinatedUniversalTime(DateTime value)

Parameters

value DateTime

The value to convert.

Returns

CoordinatedUniversalTime

A CoordinatedUniversalTime that is equivalent to value.

implicit operator CoordinatedUniversalTime(DateTimeOffset)

Performs an implicit conversion from DateTimeOffset to CoordinatedUniversalTime.

public static implicit operator CoordinatedUniversalTime(DateTimeOffset value)

Parameters

value DateTimeOffset

The value to convert.

Returns

CoordinatedUniversalTime

A CoordinatedUniversalTime that is equivalent to value.

See Also