format weekday on current week
This commit is contained in:
parent
af360fda53
commit
aa61301b17
@ -1,3 +1,4 @@
|
|||||||
|
import 'package:filcnaplo_kreta_api/models/week.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:i18n_extension/i18n_widget.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;
|
if (now.year == this.year && now.month == this.month && now.add(Duration(days: 1)).day == this.day) return "Tomorrow".i18n;
|
||||||
|
|
||||||
String formatString;
|
String formatString;
|
||||||
if (this.year == now.year)
|
|
||||||
formatString = "MMM dd.";
|
|
||||||
else
|
|
||||||
formatString = "yy/MM/dd";
|
|
||||||
|
|
||||||
if (weekday) formatString += " (EEEE)";
|
// 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."; // ex. Jan. 01.
|
||||||
|
else
|
||||||
|
formatString = "yy/MM/dd"; // ex. 21/01/01
|
||||||
|
|
||||||
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit f15aa89bf5f911b9e641a8b62e90e56727ac037e
|
Subproject commit a19ca7e8f76bd7285da2503c83539bca095670dd
|
Loading…
x
Reference in New Issue
Block a user