in_date_range 1.0.1 icon indicating copy to clipboard operation
in_date_range: ^1.0.1 copied to clipboard

Encapsulates a start and end DateTime that represent the range of dates.

in_date_range #

pub package innim lint Dart

Encapsulates a start and end DateTime that represent the range of dates.

Usage #

Create DateRange that contains information about a range of dates:

final range = DateRange(
    DateTime(2021, 6, 9, 18, 20),
    DateTime(2021, 6, 10, 17, 00),
);

You can easily create common ranges, such as:

// Today
final today = DateRange.today();

// Day, that contains specefied DateTime
final week = DateRange.day(DateTime(2021, 6, 9));

// Week, that contains specefied DateTime
final week = DateRange.week(DateTime(2021, 6, 9));

// Specify first wekkday if you need it
final weekFromSunday = DateRange.week(
    DateTime(2021, 6, 9), 
    firstWeekday: DateTime.sunday,
);

// Month, that contains specefied DateTime
final month = DateRange.month(DateTime(2021, 6, 9));

// Year, that contains specefied DateTime
final year = DateRange.year(DateTime(2021, 6, 9));

When you have DateRange instance, you can check if specified DateTime is in range:

final range = DateRange(
    DateTime(2021, 6, 9, 18, 20),
    DateTime(2021, 7, 20, 17, 00),
);
final date = DateTime(2021, 6, 11);

if (range.contains(date)) {
    print('Range contains $date');
}

And there is more, see the API documentation.

1
likes
120
pub points
16%
popularity

Publisher

verified publisher iconinnim.ru

Encapsulates a start and end DateTime that represent the range of dates.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

Icon for licenses.BSD-3-Clause (LICENSE)

Dependencies

equatable, in_date_utils

More

Packages that depend on in_date_range