date_checker 1.0.0+2 copy "date_checker: ^1.0.0+2" to clipboard
date_checker: ^1.0.0+2 copied to clipboard

Convenient extension methods on DateTime plus other helpful utility methods.

example/README.md

Usage #

weekStart #

Returns the beginning of the week in which date is present

var moonLanding = DateTime.parse("1969-07-20 20:18:04Z");
moonLanding.weekday == DateTime.sunday  // true

// 1969-07-14 00:00:00.000
weekStart(date: moonLanding);   

// 1969-07-20 00:00:00.000
weekStart(date: moonLanding, isMondayStartOfWeek: false)   

weekEnd #

Returns the end of the week in which date is present

var moonLanding = DateTime.parse("1969-07-20 20:18:04Z");

// 1969-07-20 23:59:59.999999
weekEnd(date: moonLanding);

// 1969-07-26 23:59:59.999999
weekEnd(date: moonLanding, isMondayStartOfWeek: false)

DateTime(1969, 7, 26).weekday == DateTime.saturday //true

If date is not specified, DateTime.now() is considered i.e. the start/end of the current week will be returned.

If isMondayStartOfWeek is not specified, defaulting to true the start/end will follow ISO 8601 and the week will be of the form [Monday...Sunday] or setting it to false will return in the form of [Sunday...Saturday]

Extension on DateTime #

Extension Method Description
isToday Returns true if date is today
isTomorrow Returns true if date is tomorrow
isYesterday Returns true if date is yesterday
isLastWeek Returns true if date is from last week
isThisWeek Returns true if date is from current week
isThisMonth Returns true if date is present in current month

By default, isLastWeek and isThisWeek will return the result based on [Monday...Sunday] format. If the Sunday is desired as the first day of the week, use the setter sundayAsStartOfWeekto acheive the result based on [Sunday...Saturday] week format.

A simple usage example:

import 'package:date_checker/date_checker.dart';

void main() {
  var date = DateTime.now();

  final isToday = date.isToday; //true
}

Features and bugs #

Please file feature requests and bugs at the issue tracker.

5
likes
130
pub points
59%
popularity

Publisher

verified publishercalvingonsalves.com

Convenient extension methods on DateTime plus other helpful utility methods.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

More

Packages that depend on date_checker