HandyDateTime extension
A handy extension for the DateTimes.
- on
Methods
-
copyWith(
{int? year, int? month, int? day, int? hour, int? minute, int? second, int? millisecond, int? microsecond}) → DateTime - Returns a copy of the current DateTime instance. If an optional parameter is set, the new DateTime will have that value.
-
leftTruncate(
TimePrecision precision) → DateTime - Returns a new DateTime with it's fields set to their default values starting from the largest time unit up to the smallest time unit.
-
rightTruncate(
TimePrecision precision) → DateTime - Returns a new DateTime with it's fields set to their default values starting from the smallest time unit up to the largest time unit.
-
timeFromLast(
TimePrecision precision) → Duration -
Returns the duration from the last
precision
-
timeTillNext(
TimePrecision precision) → Duration -
Returns the duration till the next
precision
-
truncate(
{bool year = false, bool month = false, bool day = false, bool hour = false, bool minute = false, bool second = false, bool millisecond = false, bool microsecond = false}) → DateTime - Returns a new DateTime with all its fields set to their default value. If a parameter is set to true, it keeps its current value.
-
value(
TimePrecision precision) → int -
Programmatically returns the value of the given
precision
.
Operators
-
operator <(
DateTime other) → bool -
Returns true if the current DateTime instance isBefore the
other
instance and vice versa. -
operator <=(
DateTime other) → bool -
Returns true if the current DateTime instance isBefore or isAtSameMomentAs the
other
instance and vice versa. -
operator >(
DateTime other) → bool -
Returns true if the current DateTime instance isAfter the
other
instance and vice versa. -
operator >=(
DateTime other) → bool -
Returns true if the current DateTime instance isAfter or isAtSameMomentAs the
other
instance and vice versa.