computeTimePartitionText function
Compute Time partition of messages based on created at time stamp
Implementation
String computeTimePartitionText(int millisecondsSinceEpoch) {
DateTime date = DateTime.fromMillisecondsSinceEpoch(millisecondsSinceEpoch);
DateTime now = DateTime.now();
int longAgo = now.difference(date).inDays;
String result;
switch (longAgo) {
case 0:
result = "TODAY";
break;
case 1:
result = "YESTERDAY";
break;
default:
if (longAgo <= 6) {
result = getWeekDayName(date.weekday);
} else {
result = '${date.day}/${date.month}/${date.year}';
}
}
return result;
}