/// <summary> /// Returns a string representation of the value. /// </summary> /// <returns>A string representation of the value.</returns> public override string ToString() { if (IsValidDateTime) { return(BsonUtils.ToDateTimeFromMillisecondsSinceEpoch(_millisecondsSinceEpoch).ToString("yyyy-MM-ddTHH:mm:ss.FFFFFFFK")); } else { return(XmlConvert.ToString(_millisecondsSinceEpoch)); } }
/// <summary> /// Converts the BsonDateTime value to a .NET DateTime value in UTC. /// </summary> /// <returns>A DateTime in UTC.</returns> public DateTime ToUniversalTime() { return(BsonUtils.ToDateTimeFromMillisecondsSinceEpoch(_millisecondsSinceEpoch)); }
/// <summary> /// Converts the BsonDateTime value to a .NET DateTime value in the local timezone. /// </summary> /// <returns>A DateTime in the local timezone.</returns> public DateTime ToLocalTime() { var utcDateTime = BsonUtils.ToDateTimeFromMillisecondsSinceEpoch(_millisecondsSinceEpoch); return(BsonUtils.ToLocalTime(utcDateTime)); }