import 'package:daydart/daydart.dart'; class DateHelper { //ignores th year an moves the Dates every time to the current year static bool isDateBetween( final DateTime date, final DateTime from, final DateTime until) { final currentDate = transformToCurrentYear(date); final currentFrom = transformToCurrentYear(from); final currentUntil = transformToCurrentYear(until); var isBetween = (currentDate.isAtSameMomentAs(currentFrom) || currentDate.isAfter(currentFrom)) && (currentDate.isAtSameMomentAs(currentUntil) || currentDate.isBefore(currentUntil)); return isBetween; } static DateTime getDateTimeByDayOfYear(final int dayOfTheYear) { final currentYear = DayDart().year(); final date = DayDart('$currentYear-01-01'); date.add(dayOfTheYear - 1, DayUnits.D); return date.toDate(); } static int getDayOfYear(final DateTime date) { return DayDart(date).dayOfYear(); } static DateTime transformToCurrentYear(final DateTime date) { final currentYear = DateTime.now().year; final newDate = DateTime(currentYear, date.month, date.day); return newDate; } }