-3

I am doing a dart code where I need to find the number of days and nights between two dates, in which the time period for night is specified as night start at 8pm and end at 5am. How to calculate the day time in minutes and night time in minutes if start time is today morning 10am and end time is tomorrow 11 am

abhijith
  • 17
  • 3

1 Answers1

0

Here's a sample code:-

int minutesBetween(DateTime from, DateTime to) {
 from = DateTime(from.year, from.month, from.day);
 to = DateTime(to.year, to.month, to.day);
 return (to.difference(from).inHours / 1440).round(); //dividing by 1440 coz a day consists of 1440 minutes
}
Piyush Kumar
  • 460
  • 2
  • 7
  • sorry, this didn't meet my requirement, i have to get the count of days and nights in minutes and daytime and night time have specific range – abhijith Aug 11 '21 at 06:58