relative method
String
relative(
- Duration duration, {
- bool dropPrefixOrSuffix = false,
- Abbreviation form = Abbreviation.none,
override
Please note that Mongolian language string is not in it's base form. A suffix has been added to work with relativePast
, relativeFuture
.
Implementation
@override
String relative(
Duration duration, {
bool dropPrefixOrSuffix = false,
Abbreviation form = Abbreviation.none,
}) {
final bool past = duration.isNegative;
duration = duration.abs();
DurationInterval interval = MomentLocalization.relativeThreshold(duration);
String value = getUnit(
interval,
form,
dropPrefixOrSuffix: dropPrefixOrSuffix,
);
if (!interval.singular) {
value = value.replaceAll(
srDelta,
DurationUnit.relativeDuration(duration, interval.unit).toString(),
);
}
if (dropPrefixOrSuffix) return value;
return past ? relativePast(value) : relativeFuture(value);
}