fromNowPrecise method
String
fromNowPrecise({
- bool round = true,
- bool omitZeros = true,
- bool includeWeeks = true,
- Abbreviation form = Abbreviation.none,
- String? delimiter,
- DurationFormat format = DurationFormat.auto,
- bool dropPrefixOrSuffix = false,
Example when using LocalizationEnUs:
If this is yesterday, will result "1 day ago"
If this is tomorrow, will result "in 1 day"
This will return precise durations. For imprecise durations, use from()
e.g.:
- 2 minutes 39 seconds ago
- in 2m 39s
Params:
format
- format to display the duration. For example, when set toDurationFormat.md
, will result to "3 months 2 days"delimiter
- string to join duration when there are more than one. Defaults to space. For example,form
- Unit string form. For example, minute would look like "18 minutes", "18 min", "18m" in full, mid, short forms, respectively.round
- rounds the smallest unit if true, or truncates. Defaults to true.omitZeros
- unit will be omitted if equal to zero. For example,DurationFormat.md
may return "3 months", but not "3 months 0 days"includeWeeks
- Whetherweek
should be treated as duration unit. Only applicable when using DurationFormat.autodropPrefixOrSuffix
- Whether to drop suffix/prefix. For example, "3h 2m ago" => "3h 2m", "in 7 days" => "7 days"
Implementation
String fromNowPrecise({
bool round = true,
bool omitZeros = true,
bool includeWeeks = true,
Abbreviation form = Abbreviation.none,
String? delimiter,
DurationFormat format = DurationFormat.auto,
bool dropPrefixOrSuffix = false,
}) =>
fromPrecise(
DateTimeConstructors.nowWithTimezone(isUtc),
round: round,
omitZeros: omitZeros,
includeWeeks: includeWeeks,
form: form,
delimiter: delimiter,
format: format,
dropPrefixOrSuffix: dropPrefixOrSuffix,
);