short property
Returns short text representing this DateTime.
Returns string in format Hm
, if DateTime is within today. Returns a
short weekday name, if difference between this DateTime and
DateTime.now is less than 7 days. Otherwise returns a string in yMdHm
format.
Implementation
String get short {
final DateTime now = DateTime.now();
final DateTime from = DateTime(now.year, now.month, now.day);
final DateTime to = DateTime(year, month, day);
final int differenceInDays = from.difference(to).inDays;
if (differenceInDays > 6) {
return yMd;
} else if (differenceInDays < 1) {
return hm;
} else {
return 'label_days_short'.l10nfmt({'days': differenceInDays});
}
}