diff --git a/packages/uni_app/lib/model/utils/day_of_week.dart b/packages/uni_app/lib/model/utils/day_of_week.dart index 77f78d9d3..579c4e991 100644 --- a/packages/uni_app/lib/model/utils/day_of_week.dart +++ b/packages/uni_app/lib/model/utils/day_of_week.dart @@ -8,6 +8,28 @@ enum DayOfWeek { sunday } +DayOfWeek parseDateTime(DateTime dateTime) { + final weekDay = dateTime.weekday; + switch (weekDay) { + case DateTime.monday: + return DayOfWeek.monday; + case DateTime.tuesday: + return DayOfWeek.tuesday; + case DateTime.wednesday: + return DayOfWeek.wednesday; + case DateTime.thursday: + return DayOfWeek.thursday; + case DateTime.friday: + return DayOfWeek.friday; + case DateTime.saturday: + return DayOfWeek.saturday; + case DateTime.sunday: + return DayOfWeek.sunday; + default: + throw Exception('Invalid day of week'); + } +} + DayOfWeek? parseDayOfWeek(String str) { final weekDay = str.replaceAll(' ', '').toLowerCase(); if (weekDay == 'segunda-feira') {