Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add weekdays to homework card #1248

Merged
merged 2 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,38 @@ class StudentHomeworkViewFactory {

String _getLocaleDateString(Date date, {String? time}) {
final months = {
1: 'Januar',
2: 'Februar',
3: 'März',
4: 'April',
1: 'Jan',
2: 'Feb',
3: 'Mär',
4: 'Apr',
5: 'Mai',
6: 'Juni',
7: 'Juli',
8: 'August',
9: 'September',
10: 'Oktober',
11: 'November',
12: 'Dezember',
6: 'Jun',
7: 'Jul',
8: 'Aug',
9: 'Sep',
10: 'Okt',
11: 'Nov',
12: 'Dez',
};
assert(months.containsKey(date.month));

final day = date.day.toString();
final month = months[date.month];
final year = date.year.toString();
// The year suffix is the last two digits of the year, e.g. 2019 -> 19
final yearSuffix = date.year.toString().substring(2);

final dateString = '$day. $month $year';
final weekdays = {
1: 'Mo',
2: 'Di',
3: 'Mi',
4: 'Do',
5: 'Fr',
6: 'Sa',
7: 'So',
};
final weekday = weekdays[date.asDateTime().weekday];

final dateString = '$weekday, $day. $month $yearSuffix';
if (time == null) return dateString;
return '$dateString - $time Uhr';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void main() {
colorDate: false,
subjectColor: white,
subject: 'Mathematik',
todoDate: '28. Januar 2019',
todoDate: 'Mo, 28. Jan 19',
withSubmissions: false,
title: 'S. 35 6a) und 8c)',
);
Expand Down Expand Up @@ -82,7 +82,7 @@ void main() {

final view = viewFactory.createFrom(hw);

expect(view.todoDate, '3. Dezember 2018');
expect(view.todoDate, 'Mo, 3. Dez 18');
});

test(
Expand Down
Loading