Covert Week to Date

mail@pastecode.io avatar
unknown
dart
3 years ago
497 B
5
Indexable
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}';
}