-
-
Notifications
You must be signed in to change notification settings - Fork 51
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
Replace DateTime.now()
with clock.now()
.
#1314
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -9,6 +9,7 @@ | |||
import 'dart:async'; | ||||
|
||||
import 'package:bloc_base/bloc_base.dart'; | ||||
import 'package:clock/clock.dart'; | ||||
import 'package:date/date.dart'; | ||||
import 'package:design/design.dart'; | ||||
import 'package:firebase_hausaufgabenheft_logik/firebase_hausaufgabenheft_logik.dart'; | ||||
|
@@ -52,7 +53,7 @@ extension RepeatEveryExtension<T> on Stream<T> { | |||
class DashboardBloc extends BlocBase { | ||||
final String _uid; | ||||
final todayDateTimeWithoutTime = | ||||
DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day); | ||||
DateTime(clock.now().year, clock.now().month, clock.now().day); | ||||
|
||||
final _unreadBlackboardViewsSubject = BehaviorSubject<List<BlackboardView>>(); | ||||
final _unreadBlackboardItemsEmptySubject = BehaviorSubject<bool>(); | ||||
|
@@ -152,7 +153,7 @@ class DashboardBloc extends BlocBase { | |||
|
||||
List<HomeworkDto> _filterUrgentHomeworks( | ||||
List<HomeworkDto> allHomeworks, TypeOfUser typeOfUser) { | ||||
final now = DateTime.now(); | ||||
final now = clock.now(); | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The use of - final dayAfterTomorrow = DateTime(now.year, now.month, now.day + 2);
+ final dayAfterTomorrow = now.add(Duration(days: 2)); Committable suggestion
Suggested change
|
||||
final dayAfterTomorrow = DateTime(now.year, now.month, now.day + 2); | ||||
// Was passiert, wenn der 30. Oktober ist und 2 Tage dazu gezählt werden? Springt es dann auf den 1. November um? | ||||
// Antwort: Springt um auf den 1.November, gechekt, auf wenn der Code unschön ist, besser wäre dayAfterTomorrow = now.add(Duration(days:2)) | ||||
|
@@ -286,7 +287,7 @@ extension on DateTime { | |||
bool get isDayAfterTomorrow => dayAfterTomorrow == withoutTime; | ||||
|
||||
static DateTime get today => | ||||
DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day); | ||||
DateTime(clock.now().year, clock.now().month, clock.now().day); | ||||
static DateTime get tomorrow => | ||||
DateTime(today.year, today.month, today.day + 1); | ||||
static DateTime get dayAfterTomorrow => | ||||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -8,27 +8,28 @@ | |||||||||
|
||||||||||
import 'package:analytics/analytics.dart'; | ||||||||||
import 'package:bloc_provider/bloc_provider.dart'; | ||||||||||
import 'package:clock/clock.dart'; | ||||||||||
import 'package:common_domain_models/common_domain_models.dart'; | ||||||||||
import 'package:firebase_hausaufgabenheft_logik/firebase_hausaufgabenheft_logik.dart'; | ||||||||||
import 'package:flutter/material.dart'; | ||||||||||
import 'package:group_domain_models/group_domain_models.dart'; | ||||||||||
import 'package:intl/intl.dart'; | ||||||||||
import 'package:sharezone/main/application_bloc.dart'; | ||||||||||
import 'package:sharezone/homework/parent/src/homework_card_bloc.dart'; | ||||||||||
import 'package:sharezone/dashboard/models/homework_view.dart'; | ||||||||||
import 'package:sharezone/groups/src/pages/course/course_card.dart'; | ||||||||||
import 'package:sharezone/homework/teacher/homework_done_by_users_list/homework_completion_user_list_page.dart'; | ||||||||||
import 'package:sharezone/homework/homework_details/homework_details.dart'; | ||||||||||
import 'package:sharezone/homework/homework_details/homework_details_view_factory.dart'; | ||||||||||
import 'package:sharezone/homework/shared/homework_permissions.dart'; | ||||||||||
import 'package:sharezone/homework/parent/homework_page.dart'; | ||||||||||
import 'package:sharezone/homework/parent/src/homework_card_bloc.dart'; | ||||||||||
import 'package:sharezone/homework/shared/delete_homework.dart'; | ||||||||||
import 'package:sharezone/homework/shared/homework_permissions.dart'; | ||||||||||
import 'package:sharezone/homework/teacher/homework_done_by_users_list/homework_completion_user_list_page.dart'; | ||||||||||
import 'package:sharezone/main/application_bloc.dart'; | ||||||||||
import 'package:sharezone/report/page/report_page.dart'; | ||||||||||
import 'package:sharezone/report/report_icon.dart'; | ||||||||||
import 'package:sharezone/report/report_item.dart'; | ||||||||||
import 'package:sharezone/submissions/homework_list_submissions_page.dart'; | ||||||||||
import 'package:sharezone/util/api/connections_gateway.dart'; | ||||||||||
import 'package:sharezone/util/navigation_service.dart'; | ||||||||||
import 'package:sharezone/homework/shared/delete_homework.dart'; | ||||||||||
import 'package:sharezone_widgets/sharezone_widgets.dart'; | ||||||||||
import 'package:user/user.dart'; | ||||||||||
|
||||||||||
|
@@ -52,8 +53,8 @@ class HomeworkCard extends StatelessWidget { | |||||||||
final bloc = HomeworkCardBloc(api, homework!); | ||||||||||
final analytics = BlocProvider.of<SharezoneContext>(context).analytics; | ||||||||||
|
||||||||||
DateTime tomorrowWithoutTime = DateTime( | ||||||||||
DateTime.now().year, DateTime.now().month, DateTime.now().day + 1); | ||||||||||
DateTime tomorrowWithoutTime = | ||||||||||
DateTime(clock.now().year, clock.now().month, clock.now().day + 1); | ||||||||||
Comment on lines
+56
to
+57
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The replacement of - DateTime tomorrowWithoutTime =
- DateTime(clock.now().year, clock.now().month, clock.now().day + 1);
+ final now = clock.now();
+ DateTime tomorrowWithoutTime = DateTime(now.year, now.month, now.day + 1); Committable suggestion
Suggested change
|
||||||||||
DateTime todoUntilWithoutTime = DateTime(homework!.todoUntil.year, | ||||||||||
homework!.todoUntil.month, homework!.todoUntil.day); | ||||||||||
|
||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The calculation of
todayDateTimeWithoutTime
usingclock.now()
is correct and aligns with the objective of making the code more testable. However, consider simplifying the expression by using a single call toclock.now()
to improve readability and performance.Committable suggestion