from method
Returns a string representation of current Jiffy's instance relative
from jiffy
's date and time, with optional withPrefixAndSuffix
flag
to include prefix and suffix like "in" or "ago".
Example:
final jiffy1 = Jiffy.parseFromDateTime(DateTime(2023, 1, 1));
final jiffy2 = Jiffy.parseFromDateTime(DateTime(2023, 2, 1));
print(jiffy1.from(jiffy2));
// output: a month ago
Example without returning prefix and suffix:
final jiffy1 = Jiffy.parseFromDateTime(DateTime(2023, 1, 1));
final jiffy2 = Jiffy.parseFromDateTime(DateTime(2023, 2, 1));
print(jiffy1.from(jiffy2, withPrefixAndSuffix: false));
// output: a month
If withPrefixAndSuffix
is true
(default), the output string will
include prefix and suffix words like "in" or "ago". Otherwise, only
the relative time difference string will be returned.
Implementation
String from(Jiffy jiffy, {bool withPrefixAndSuffix = true}) {
return _display.fromAsRelativeDateTime(
dateTime, jiffy.dateTime, _locale, withPrefixAndSuffix);
}