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
-
objectCoordinatedUniversalTime
- 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
valueDateTimeThe DateTime value to assign the role of CoordinatedUniversalTime.
Exceptions
- ArgumentException
valueis 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
MinValue
Denotes the smallest possible value of CoordinatedUniversalTime.
public static readonly CoordinatedUniversalTime MinValue
Field Value
Methods
FromString(string)
Converts the string representation of a date and time to its CoordinatedUniversalTime> equivalent.
public static CoordinatedUniversalTime FromString(string value)
Parameters
valuestringA 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
Operators
implicit operator DateTime(CoordinatedUniversalTime)
Performs an implicit conversion from CoordinatedUniversalTime to DateTime.
public static implicit operator DateTime(CoordinatedUniversalTime value)
Parameters
valueCoordinatedUniversalTimeThe value to convert.
Returns
implicit operator CoordinatedUniversalTime(DateTime)
Performs an implicit conversion from DateTime to CoordinatedUniversalTime.
public static implicit operator CoordinatedUniversalTime(DateTime value)
Parameters
valueDateTimeThe 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
valueDateTimeOffsetThe value to convert.
Returns
- CoordinatedUniversalTime
A CoordinatedUniversalTime that is equivalent to
value.