DateTimeExtensions extension
Extensions on DateTime
- on
Properties
- date → Date
-
Create a Date instance from a DateTime.
no setter
- endOfDay → DateTime
-
Return the end of a day for this date. The result will be in the local timezone.
no setter
- getISOWeek → int
-
Get the ISO week index
no setter
- getISOWeeksInYear → int
-
Get the number of weeks in an ISO week-numbering year
no setter
- getMonth → Month
-
Create a Month instance from a DateTime
no setter
- getYear → Year
-
Create a Year instance from a DateTime
no setter
- isLeapYear → bool
-
/////////////////////////////// COMPARISON
Is the given date in the leap year?
no setter
- isoWeek → Week
-
Create a ISO Week instance from DateTime
no setter
- startOfDay → DateTime
-
Get a DateTime representing start of Day of this DateTime in local time.
no setter
- time → Time
-
Create a Time instance from a DateTime.
no setter
- week → Week
-
Create a Week instance from a DateTime
no setter
- yearOfISOWeek → int
-
Returns the year for this DateTime ISO week
no setter
Methods
-
addDays(
int amount, {bool ignoreDaylightSavings = false}) → DateTime - Add a certain amount of days to this date
-
addHours(
int amount, {bool ignoreDaylightSavings = false}) → DateTime - Add a certain amount of hours to this date
-
addMicroseconds(
int amount, {bool ignoreDaylightSavings = false}) → DateTime - Add a certain amount of microseconds to this date
-
addMilliseconds(
int amount, {bool ignoreDaylightSavings = false}) → DateTime - Add a certain amount of milliseconds to this date
-
addMinutes(
int amount, {bool ignoreDaylightSavings = false}) → DateTime - Add a certain amount of minutes to this date
-
addMonths(
int amount) → DateTime - Add a certain amount of months to this date
-
addQuarters(
int amount) → DateTime - Add a certain amount of quarters to this date
-
addSeconds(
int amount, {bool ignoreDaylightSavings = false}) → DateTime - Add a certain amount of seconds to this date
-
addWeeks(
int amount) → DateTime - Add a certain amount of weeks to this date
-
addYears(
int amount) → DateTime - Add a certain amount of years to this date
-
copyWith(
{int? year, int? month, int? day, int? hour, int? minute, int? second, int? millisecond, int? microsecond}) → DateTime - Convenient copy with method
-
format(
[String? pattern, String? locale]) → String - Short-hand to DateFormat
-
isEqual(
DateTime other) → bool -
Check if a date is
equals
to other -
isOutside(
DateTimeRange range) → bool -
Check if the date is out side
range
-
isOutsideRange(
DateTime start, DateTime end) → bool -
Check if the date is out side
start
andend
-
isSameOrAfter(
DateTime other) → bool - Return true if other isEqual or isAfter to this date
-
isSameOrBefore(
DateTime other) → bool - Return true if other isEqual or isBefore to this date
-
isSameYear(
DateTime other) → bool - Check if this date is in the same year than other
-
isWithin(
DateTimeRange range) → bool -
Check if the date is within
range
-
isWithinRange(
DateTime start, DateTime end) → bool -
Check if the date is within
start
andend
-
subDays(
int amount, {bool ignoreDaylightSavings = false}) → DateTime - Subtract a certain amount of days from this date
-
subHours(
int amount, {bool ignoreDaylightSavings = false}) → DateTime - Subtract a certain amount of hours from this date
-
subMicroseconds(
int amount, {bool ignoreDaylightSavings = false}) → DateTime - Subtract a certain amount of microseconds from this date
-
subMilliseconds(
int amount, {bool ignoreDaylightSavings = false}) → DateTime - Subtract a certain amount of milliseconds to this date
-
subMinutes(
int amount, {bool ignoreDaylightSavings = false}) → DateTime - Subtract a certain amount of minutes from this date
-
subMonths(
int amount) → DateTime - Subtract a certain amount of months from this date
-
subQuarters(
int amount) → DateTime - Subtract a certain amount of quarters from this date
-
subSeconds(
int amount, {bool ignoreDaylightSavings = false}) → DateTime - Subtract a certain amount of seconds from this date
-
subWeeks(
int amount) → DateTime - Subtract a certain amount of weeks from this date
-
subYears(
int amount) → DateTime - Subtract a certain amount of years from this date
Operators
-
operator +(
Duration duration) → DateTime - ////////////////////////////////// OPERATION Adds this DateTime and Duration and returns the sum as a new DateTime object.
-
operator -(
Duration duration) → DateTime - Subtracts the Duration from this DateTime returns the difference as a new DateTime object.
-
operator <(
DateTime other) → bool - Less than
-
operator <=(
DateTime other) → bool - Less than or equal
-
operator >(
DateTime other) → bool - Greater than
-
operator >=(
DateTime other) → bool - Greater than or equal