feat: add validated semester and lesson calculations
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
class Semester {
|
||||
Semester({required DateTime startDate, required this.totalWeeks})
|
||||
: startDate = DateTime.utc(startDate.year, startDate.month, startDate.day) {
|
||||
if (totalWeeks < 1 || totalWeeks > 30) {
|
||||
throw ArgumentError('学期周数应为 1–30');
|
||||
}
|
||||
}
|
||||
DateTime get firstMonday =>
|
||||
startDate.subtract(Duration(days: startDate.weekday - 1));
|
||||
final DateTime startDate;
|
||||
final int totalWeeks;
|
||||
}
|
||||
Reference in New Issue
Block a user