Show year within gallery if not within the same year

This commit is contained in:
Vishnu Mohandas 2020-11-14 16:41:43 +05:30
parent 632ec72f07
commit ed80f9dc9f
2 changed files with 9 additions and 3 deletions

View file

@ -208,11 +208,17 @@ class _GalleryState extends State<Gallery> {
}
Widget _getDay(int timestamp) {
var date = DateTime.fromMicrosecondsSinceEpoch(timestamp);
var title = getDayAndMonth(date);
if (date.year != DateTime.now().year) {
title += " " + date.year.toString();
}
return Container(
padding: const EdgeInsets.all(8.0),
alignment: Alignment.centerLeft,
child: Text(
getDayAndMonth(DateTime.fromMicrosecondsSinceEpoch(timestamp)),
title,
style: TextStyle(fontSize: 16),
),
);

View file

@ -45,9 +45,9 @@ String getMonthAndYear(DateTime dateTime) {
String getDayAndMonth(DateTime dateTime) {
return _days[dateTime.weekday] +
", " +
_months[dateTime.month] +
dateTime.day.toString() +
" " +
dateTime.day.toString();
_months[dateTime.month];
}
String getDay(DateTime dateTime) {