NullableDateTimeComparisonExtensions extension

Extension providing comparison operators for nullable DateTime objects Adds <=, >=, >, < operators for DateTime? with DateTime and DateTime?

on

Methods

compareToSafely(DateTime? other) int?

Available on DateTime?, provided by the NullableDateTimeComparisonExtensions extension

Safe comparison method that returns null if either operand is null Useful when you want to explicitly handle null cases
isBetween(DateTime? start, DateTime? end) bool

Available on DateTime?, provided by the NullableDateTimeComparisonExtensions extension

Check if this DateTime is between two other DateTimes (inclusive) Returns false if any of the DateTimes is null
isBetweenExclusive(DateTime? start, DateTime? end) bool

Available on DateTime?, provided by the NullableDateTimeComparisonExtensions extension

Check if this DateTime is between two other DateTimes (exclusive) Returns false if any of the DateTimes is null
isEqualTo(DateTime? other) bool

Available on DateTime?, provided by the NullableDateTimeComparisonExtensions extension

Check if this nullable DateTime equals another nullable DateTime Returns true only if both are null or both have same moment

Operators

operator <(DateTime? other) bool

Available on DateTime?, provided by the NullableDateTimeComparisonExtensions extension

Less than operator for nullable DateTime with DateTime Returns false if this is null
operator <=(DateTime? other) bool

Available on DateTime?, provided by the NullableDateTimeComparisonExtensions extension

Less than or equal operator for nullable DateTime with DateTime Returns false if this is null
operator >(DateTime? other) bool

Available on DateTime?, provided by the NullableDateTimeComparisonExtensions extension

Greater than operator for nullable DateTime with DateTime Returns false if this is null
operator >=(DateTime? other) bool

Available on DateTime?, provided by the NullableDateTimeComparisonExtensions extension

Greater than or equal operator for nullable DateTime with DateTime Returns false if this is null