in_date_utils 1.0.1
in_date_utils: ^1.0.1 copied to clipboard
Utils for DateTime. Easily modify, check and copy dates. Get numbers of days in year/month. And many more.
in_date_utils #
Another utils for DateTime.
Usage #
To use this plugin, add in_date_utils as a dependency in your pubspec.yaml file.
Than add import 'package:in_date_utils/in_date_utils.dart'; to the file for use extension methods.
Example #
import 'package:list_ext/list_ext.dart';
void main() {
final now = DateTime.now();
print(now);
// 2020-10-22 18:18:27.125878
print(DateUtils.startOfDay(now));
// 2020-10-22 00:00:00.000
print(DateUtils.isFirstDayOfWeek(now));
// false
print(DateUtils.lastDayOfMonth(now));
// 2020-10-31 00:00:00.000
print(DateUtils.getDaysInYear(2020));
// 366
print(DateUtils.getWeeksInYear(2020));
// 53
}
Methods classifier #
Comparison #
Is in same period
isSameDay()- checks if twoDateTimeinstances are on the same day.
Checks #
Week
isFirstDayOfWeek()- checks if providedDateTimeis in the first day of a week (Monday).isLastDayOfWeek()- checks if providedDateTimeis in the last day of a week (Sunday).
Month
isFirstDayOfMonth()- Checks ifDateTimeis in the first day of a month.isLastDayOfMonth()- Checks ifDateTimeis in the last day of a month.
Transformation #
Next/prev
nextDay()/previousDay()- returns same time in the next/previous day.nextYear()/previousYear()- returns same date in the next/previous year.
Start/end
startOfDay()- returnsDateTimefor the beginning of the day (00:00:00).startOfNextDay()- returnsDateTimefor the beginning of the next day (00:00:00).startOfToday()- returnsDateTimefor the beginning of today (00:00:00).firstDayOfWeek()- returnsDateTimefor the beginning of the first day of the week for specified date.firstDayOfNextWeek()- returnsDateTimefor the beginning of the first day of the next week for specified date.lastDayOfWeek()- returnsDateTimefor the beginning of the last day of the week for specified date.firstDayOfFirstWeek()- returns start of the first day of the first week in year.
Information #
getDaysInMonth()- returns number of days in the month of the year.getDayNumberInYear()- returns number of the day in year.getDayNumberInWeek()- returns number of the day in week.getWeekNumber()- returns number of the week in year.getLastWeekNumber()- returns number of the last week in year.getDaysDifference()- returns count of days between two dates.
Generation #
generateWithDayStep()- returns an iterable ofDateTimein given range with 1 day step.