relativeThreshold static method
Uses MomentLocalization._relativeThresholds
map. Refer to this table for details:
https://momentjs.com/docs/#/displaying/fromnow/
Implementation
static DurationInterval relativeThreshold(Duration duration) {
final Duration absoluteDuration = duration.abs();
for (DurationInterval key in _relativeThresholds.keys) {
final Duration? maxDuration = _relativeThresholds[key];
if (maxDuration == null) return key;
if (absoluteDuration < maxDuration) {
return key;
}
}
throw MomentException("Something went wrong");
}