Another utils for DateTime
.
To use this plugin, add in_date_utils
as a dependency in your pubspec.yaml file.
import 'package:in_date_utils/in_date_utils.dart';
void main() {
final now = DTU.now();
print(now);
// 2020-10-22 18:18:27.125878
print(DTU.startOfDay(now));
// 2020-10-22 00:00:00.000
print(DTU.isFirstDayOfWeek(now));
// false
print(DTU.lastDayOfMonth(now));
// 2020-10-31 00:00:00.000
print(DTU.getDaysInYear(2020));
// 366
print(DTU.getWeeksInYear(2020));
// 53
}
now()
- returns currentDateTime
.
isSameDay()
- checks if twoDateTime
instances are on the same day.
max()
- returns the latest of two dates.min()
- returns the earliest of two dates.
isFirstDayOfWeek()
- checks if providedDateTime
is in the first day of a week (Monday).isLastDayOfWeek()
- checks if providedDateTime
is in the last day of a week (Sunday).
isFirstDayOfMonth()
- Checks ifDateTime
is in the first day of a month.isLastDayOfMonth()
- Checks ifDateTime
is in the last day of a month.
nextDay()
/previousDay()
- returns same time in the next/previous day.nextYear()
/previousYear()
- returns same date and time in the next/previous year.
startOfDay()
- returnsDateTime
for the beginning of the day (00:00:00).startOfNextDay()
- returnsDateTime
for the beginning of the next day (00:00:00).startOfToday()
- returnsDateTime
for the beginning of today (00:00:00).firstDayOfWeek()
- returnsDateTime
for the beginning of the first day of the week for specified date.firstDayOfNextWeek()
- returnsDateTime
for the beginning of the first day of the next week for specified date.lastDayOfWeek()
- returnsDateTime
for 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.
addDays()
- Returns theDateTime
resulting from adding the given number of months to thisDateTime
.addWeeks()
- Returns theDateTime
resulting from adding the given number of weeks to thisDateTime
.addMonth()
- Returns theDateTime
resulting from adding the given number of days to thisDateTime
.addYears()
- Returns theDateTime
resulting from adding the given number of years to thisDateTime
.
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.
generateWithDayStep()
- returns an iterable ofDateTime
in given range with 1 day step.