format weekday on current week
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import 'package:filcnaplo_kreta_api/models/week.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:i18n_extension/i18n_widget.dart';
|
||||
@@ -45,13 +46,18 @@ extension DateFormatUtils on DateTime {
|
||||
if (now.year == this.year && now.month == this.month && now.add(Duration(days: 1)).day == this.day) return "Tomorrow".i18n;
|
||||
|
||||
String formatString;
|
||||
|
||||
// If date is current week, show only weekday
|
||||
if (Week.current().start.isBefore(this) && Week.current().end.isAfter(this))
|
||||
formatString = "EEEE"; // ex. monday
|
||||
else {
|
||||
if (this.year == now.year)
|
||||
formatString = "MMM dd.";
|
||||
formatString = "MMM dd."; // ex. Jan. 01.
|
||||
else
|
||||
formatString = "yy/MM/dd";
|
||||
formatString = "yy/MM/dd"; // ex. 21/01/01
|
||||
|
||||
if (weekday) formatString += " (EEEE)";
|
||||
|
||||
return DateFormat(formatString, I18n.of(context).locale.toString()).format(this);
|
||||
if (weekday) formatString += " (EEEE)"; // ex. (monday)
|
||||
}
|
||||
return DateFormat(formatString, I18n.of(context).locale.toString()).format(this).capital();
|
||||
}
|
||||
}
|
||||
|
||||
Submodule filcnaplo_mobile_ui updated: f15aa89bf5...a19ca7e8f7
Reference in New Issue
Block a user