DateTimeScrewdriver extension

Provides extensions for DateTime class.

on

Properties

dateOnly DateTime
Returns an instance of DateTime without time related values. This is intended to remove hour, minute, second and millisecond information from DateTime instance which leaves only date information. Example: final date = DateTime().now(); // 26-07-2020 16:54:23 date.dateOnly // 26-07-2020 This is helpful in cases where comparison of only dates is required.
no setter
fromNow Duration
Returns Duration difference between this and current time
no setter
isFriday bool
Returns true if this occurs on Friday In accordance with ISO 8601, a week starts with Monday, which has the value 1.
no setter
isFuture bool
Returns true if this occurs in future This doesn't account for time.
no setter
isInApril bool
Returns true if this falls in april
no setter
isInAugust bool
Returns true if this falls in august
no setter
isInDecember bool
Returns true if this falls in december
no setter
isInFebruary bool
Returns true if this falls in february
no setter
isInJanuary bool
Returns true if this falls in january
no setter
isInJuly bool
Returns true if this falls in july
no setter
isInJune bool
Returns true if this falls in june
no setter
isInMarch bool
Returns true if this falls in march
no setter
isInMay bool
Returns true if this falls in may
no setter
isInNextMonth bool
Returns true if this occurs in previous month
no setter
isInNextYear bool
Returns true if this occurs in previous year
no setter
isInNovember bool
Returns true if this falls in november
no setter
isInOctober bool
Returns true if this falls in october
no setter
isInPreviousMonth bool
Returns true if this occurs in previous month
no setter
isInPreviousYear bool
Returns true if this occurs in previous year
no setter
isInSeptember bool
Returns true if this falls in september
no setter
isMonday bool
Returns true if this occurs on Monday In accordance with ISO 8601, a week starts with Monday, which has the value 1.
no setter
isPast bool
Returns true if this occurs in past This doesn't account for time.
no setter
isSaturday bool
Returns true if this occurs on Saturday In accordance with ISO 8601, a week starts with Monday, which has the value 1.
no setter
isSunday bool
Returns true if this occurs on Sunday In accordance with ISO 8601, a week starts with Monday, which has the value 1.
no setter
isThursday bool
Returns true if this occurs on Thursday In accordance with ISO 8601, a week starts with Monday, which has the value 1.
no setter
isToday bool
Returns true if this is same as the date of today. This doesn't account for time.
no setter
isTomorrow bool
Returns true if this occurs a day after today This doesn't account for time.
no setter
isTuesday bool
Returns true if this occurs on Tuesday In accordance with ISO 8601, a week starts with Monday, which has the value 1.
no setter
isWednesday bool
Returns true if this occurs on Wednesday In accordance with ISO 8601, a week starts with Monday, which has the value 1.
no setter
isYesterday bool
Returns true if this occurs a day before today This doesn't account for time.
no setter
nextDay DateTime
Returns DateTime with next day
no setter
nextYear DateTime
Returns DateTime with next year
no setter
previousDay DateTime
Returns DateTime with previous day
no setter
previousYear DateTime
Returns DateTime with previous year
no setter

Methods

isAfterDate(DateTime other) bool
Returns true if the date of this occurs after the date of other.
isBeforeDate(DateTime other) bool
Returns true if the date of this occurs before the date of other.
isBetween(DateTime date1, DateTime date2) bool
Returns true if this falls between date1 and date2 irrespective of the order in the Calender.
isSameDateAs(DateTime other) bool
Returns true if the date of this occurs on the same day as the date of other.
only({int? year, int month = 1, int day = 1, int hour = 0, int minute = 0, int second = 0, int millisecond = 0, int microsecond = 0}) DateTime
Returns DateTime with only information that is passed to the method. In contrast to DateTime.copyWith method, this method does not copy unspecified fields from the original DateTime.
truncateMicros() DateTime
Removes any information that is equal to or smaller than milliseconds. Returned instance will have 0 milliseconds and microseconds.
truncateMillis() DateTime
Removes any information that is equal to or smaller than milliseconds. Returned instance will have 0 milliseconds and microseconds.
truncateMinutes() DateTime
Removes any information that is equal to or smaller than minutes. Returned instance will have 0 minutes, seconds, milliseconds and microseconds.
truncateSeconds() DateTime
Removes any information that is equal to or smaller than seconds. Returned instance will have 0 seconds, milliseconds and microseconds.

Operators

operator +(Duration duration) DateTime
  • operator that Adds duration to this e.g. DateTime twoDaysAfter = DateTime.now() + 2.days;
  • operator -(Duration duration) DateTime
  • operator that subtracts duration from this. e.g. DateTime fiveDaysAgo = DateTime.now() - 5.days;
  • operator <(DateTime other) bool
    Returns true if this occurs before other.
    operator <=(DateTime other) bool
    Returns true if this occurs before or at the same moment as other.
    operator >(DateTime other) bool
    Returns true if this occurs after other.
    operator >=(DateTime other) bool
    Returns true if this occurs after or at the same moment as other.