Covert Week to Date

mail@pastecode.io avatar
unknown
dart
2 years ago
497 B
5
Indexable
Never
String firstDateOfWeek(int week, int year) {
  DateTime date = DateTime.parse('$year-01-01');
  DateTime convertedDate = date.add(Duration(days: (week * 7) - 7));
  return '${convertedDate.day}/${convertedDate.month}/${convertedDate.year}';
}

String lastDateOfWeek(int week, int year) {
  DateTime date = DateTime.parse('$year-01-01');
  DateTime convertedDate = date.add(Duration(days: (week * 7) - 1));
  return '${convertedDate.day}/${convertedDate.month}/${convertedDate.year}';
}