Skip to content

Commit

Permalink
feat: Updated day of the week parser to include datetime
Browse files Browse the repository at this point in the history
  • Loading branch information
HenriqueSFernandes committed Nov 16, 2024
1 parent 63aa00c commit 9e8f5c0
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions packages/uni_app/lib/model/utils/day_of_week.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down

0 comments on commit 9e8f5c0

Please sign in to comment.