Home > Software engineering >  Dart check DateTime for the last day
Dart check DateTime for the last day

Time:10-10

I have a List of different DateTime where for each month of the year there are from 7-15 days with an interval of a couple of days. For example: 01.07, 04.07, 09.07, 14.07, 20.07..., 04.08, 10.08 Question: How do I check if the date is the last for the given month? For example, the date 23.07 may be the last date for the month number 07. Thanks!

CodePudding user response:

Lets assume this is your list:

List<DateTime> dates = [
    DateTime(2022, 07, 01),
    DateTime(2022, 07, 04),
    DateTime(2022, 07, 05),
    DateTime(2022, 07, 09),
    DateTime(2022, 07, 14),
    DateTime(2022, 07, 20),
    DateTime(2022, 07, 24),
    DateTime(2022, 08, 04),
  ];

with enter image description here

  • Related