I want to know the DateTime min and max value for comparison.
DateTimes can represent time values that are at a distance of at most 100,000,000 days from epoch (1970-01-01 UTC): -271821-04-20 to 275760-09-13.
I see no min/max define in DateTime, is there any way to programmatically get the min/max values?
DateTime min; // -271821-04-20
DateTime max; // 275760-09-13
It doesn't seem like this is something that is available at the moment. You could make a feature request and see what happens, but the only thing right now is to just make getters for the max and min values. Unfortunately, we can't make static extension methods either, so you'll just have to use a static class or globals:
class DateTimeMaxMin {
static const _numDays = 100000000;
static DateTime get min => DateTime.fromMicrosecondsSinceEpoch(0).subtract(Duration(days: _numDays));
static DateTime get max => DateTime.fromMicrosecondsSinceEpoch(0).add(Duration(days: _numDays));
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With