Class BsonDateTime
Represents a BSON DateTime value.
[Serializable]
public class BsonDateTime : BsonValue, IComparable<BsonValue>, IConvertible, IEquatable<BsonValue>, IComparable<BsonDateTime>, IEquatable<BsonDateTime>
- Inheritance
-
BsonDateTime
- Implements
- Inherited Members
- Extension Methods
Constructors
BsonDateTime(DateTime)
Initializes a new instance of the BsonDateTime class.
public BsonDateTime(DateTime value)
Parameters
valueDateTimeA DateTime.
BsonDateTime(long)
Initializes a new instance of the BsonDateTime class.
public BsonDateTime(long millisecondsSinceEpoch)
Parameters
millisecondsSinceEpochlongMilliseconds since Unix Epoch.
Properties
BsonType
Gets the BsonType of this BsonValue.
public override BsonType BsonType { get; }
Property Value
IsValidDateTime
Gets whether this BsonDateTime is a valid .NET DateTime.
public override bool IsValidDateTime { get; }
Property Value
MillisecondsSinceEpoch
Gets the number of milliseconds since the Unix Epoch.
public long MillisecondsSinceEpoch { get; }
Property Value
RawValue
Gets the number of milliseconds since the Unix Epoch.
[Obsolete("Use MillisecondsSinceEpoch instead.")]
public override object RawValue { get; }
Property Value
Value
Gets the DateTime value.
[Obsolete("Use ToUniversalTime instead.")]
public DateTime Value { get; }
Property Value
Methods
CompareTo(BsonDateTime)
Compares this BsonDateTime to another BsonDateTime.
public int CompareTo(BsonDateTime other)
Parameters
otherBsonDateTimeThe other BsonDateTime.
Returns
- int
A 32-bit signed integer that indicates whether this BsonDateTime is less than, equal to, or greather than the other.
CompareTo(BsonValue)
Compares the BsonDateTime to another BsonValue.
public override int CompareTo(BsonValue other)
Parameters
otherBsonValueThe other BsonValue.
Returns
- int
A 32-bit signed integer that indicates whether this BsonDateTime is less than, equal to, or greather than the other BsonValue.
Create(object)
Creates a new BsonDateTime.
public static BsonDateTime Create(object value)
Parameters
valueobjectAn object to be mapped to a BsonDateTime.
Returns
- BsonDateTime
A BsonDateTime or null.
Equals(BsonDateTime)
Compares this BsonDateTime to another BsonDateTime.
public bool Equals(BsonDateTime rhs)
Parameters
rhsBsonDateTimeThe other BsonDateTime.
Returns
- bool
True if the two BsonDateTime values are equal.
Equals(object)
Compares this BsonDateTime to another object.
public override bool Equals(object obj)
Parameters
objobjectThe other object.
Returns
- bool
True if the other object is a BsonDateTime and equal to this one.
GetHashCode()
Gets the hash code.
public override int GetHashCode()
Returns
- int
The hash code.
IConvertibleGetTypeCodeImplementation()
Implementation of the IConvertible GetTypeCode method.
protected override TypeCode IConvertibleGetTypeCodeImplementation()
Returns
- TypeCode
The TypeCode.
IConvertibleToDateTimeImplementation(IFormatProvider)
Implementation of the IConvertible ToDateTime method.
protected override DateTime IConvertibleToDateTimeImplementation(IFormatProvider provider)
Parameters
providerIFormatProviderThe format provider.
Returns
- DateTime
A DateTime.
ToLocalTime()
Converts this BsonValue to a DateTime in local time.
public override DateTime ToLocalTime()
Returns
- DateTime
A DateTime.
ToNullableLocalTime()
Converts this BsonValue to a DateTime? in local time.
public override DateTime? ToNullableLocalTime()
Returns
- DateTime?
A DateTime?.
ToNullableUniversalTime()
Converts this BsonValue to a DateTime? in UTC.
public override DateTime? ToNullableUniversalTime()
Returns
- DateTime?
A DateTime?.
ToString()
Returns a string representation of the value.
public override string ToString()
Returns
- string
A string representation of the value.
ToUniversalTime()
Converts this BsonValue to a DateTime in UTC.
public override DateTime ToUniversalTime()
Returns
- DateTime
A DateTime.
Operators
operator ==(BsonDateTime, BsonDateTime)
Compares two BsonDateTime values.
public static bool operator ==(BsonDateTime lhs, BsonDateTime rhs)
Parameters
lhsBsonDateTimeThe first BsonDateTime.
rhsBsonDateTimeThe other BsonDateTime.
Returns
- bool
True if the two BsonDateTime values are equal according to ==.
implicit operator BsonDateTime(DateTime)
Converts a DateTime to a BsonDateTime.
public static implicit operator BsonDateTime(DateTime value)
Parameters
valueDateTimeA DateTime.
Returns
- BsonDateTime
A BsonDateTime.
operator !=(BsonDateTime, BsonDateTime)
Compares two BsonDateTime values.
public static bool operator !=(BsonDateTime lhs, BsonDateTime rhs)
Parameters
lhsBsonDateTimeThe first BsonDateTime.
rhsBsonDateTimeThe other BsonDateTime.
Returns
- bool
True if the two BsonDateTime values are not equal according to ==.