mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-17 08:15:09 +00:00
refactor: Use DateTime for weekday localization
This commit is contained in:
parent
e721dac452
commit
e754df49d2
1 changed files with 3 additions and 16 deletions
|
@ -1,4 +1,5 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||||
|
|
||||||
|
@ -59,22 +60,8 @@ extension DateTimeExtension on DateTime {
|
||||||
if (sameDay) {
|
if (sameDay) {
|
||||||
return localizedTimeOfDay(context);
|
return localizedTimeOfDay(context);
|
||||||
} else if (sameWeek) {
|
} else if (sameWeek) {
|
||||||
switch (weekday) {
|
return DateFormat.EEEE(Localizations.localeOf(context).languageCode)
|
||||||
case 1:
|
.format(this);
|
||||||
return L10n.of(context)!.monday;
|
|
||||||
case 2:
|
|
||||||
return L10n.of(context)!.tuesday;
|
|
||||||
case 3:
|
|
||||||
return L10n.of(context)!.wednesday;
|
|
||||||
case 4:
|
|
||||||
return L10n.of(context)!.thursday;
|
|
||||||
case 5:
|
|
||||||
return L10n.of(context)!.friday;
|
|
||||||
case 6:
|
|
||||||
return L10n.of(context)!.saturday;
|
|
||||||
case 7:
|
|
||||||
return L10n.of(context)!.sunday;
|
|
||||||
}
|
|
||||||
} else if (sameYear) {
|
} else if (sameYear) {
|
||||||
return L10n.of(context)!.dateWithoutYear(
|
return L10n.of(context)!.dateWithoutYear(
|
||||||
month.toString().padLeft(2, '0'),
|
month.toString().padLeft(2, '0'),
|
||||||
|
|
Loading…
Reference in a new issue