FloatingDateTime class final Dates and times
A date and time with no timezone, used for calendar layout.
The components are stored through DateTime.utc, so add and subtract step calendar units and a value renders the same in every timezone. It is not a UTC instant.
Use fromExternal to convert a zoned DateTime or TZDateTime into a FloatingDateTime, and forLocation to convert back.
- Inheritance
- Available extensions
Constructors
- FloatingDateTime(int year, [int month = 1, int day = 1, int hour = 0, int minute = 0, int second = 0, int millisecond = 0, int microsecond = 0])
- Creates a FloatingDateTime instance.
- FloatingDateTime.fromDateTime(DateTime dateTime)
- Creates a FloatingDateTime from an existing DateTime.
Properties
- day → int
-
The day of the month
[1..31].no setterinherited - dayRange → FloatingDateTimeRange
-
Returns a half-open
[start, end)range covering this entire day.no setter - endOfDay → FloatingDateTime
-
Returns midnight (00:00:00) of the next day (exclusive upper bound).
no setter
- endOfMonth → FloatingDateTime
-
Returns the first day of the next month at midnight (exclusive upper bound).
no setter
- endOfYear → FloatingDateTime
-
Returns January 1st of the next year at midnight (exclusive upper bound).
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hour → int
-
The hour of the day, expressed as in a 24-hour clock
[0..23].no setterinherited - isLeapYear → bool
-
True if this date is on a leap year.
no setter
- isStartOfDay → bool
-
Whether this date is exactly at midnight (all time components are zero).
no setter
- isUtc → bool
-
True if this DateTime is set to UTC time.
finalinherited
- microsecond → int
-
The microsecond
[0...999].no setterinherited - microsecondsSinceEpoch → int
-
The number of microseconds since
the "Unix epoch" 1970-01-01T00:00:00Z (UTC).
no setterinherited
- millisecond → int
-
The millisecond
[0...999].no setterinherited - millisecondsSinceEpoch → int
-
The number of milliseconds since
the "Unix epoch" 1970-01-01T00:00:00Z (UTC).
no setterinherited
- minute → int
-
The minute
[0...59].no setterinherited - month → int
-
The month
[1..12].no setterinherited - monthRange → FloatingDateTimeRange
-
Returns a half-open
[start, end)range covering this entire month.no setter - ordinalDate → int
-
The ordinal date, the number of days since December 31st the previous year.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- second → int
-
The second
[0...59].no setterinherited - startOfDay → FloatingDateTime
-
Returns midnight (00:00:00) of this date.
no setter
- startOfMonth → FloatingDateTime
-
Returns the first day of this date's month at midnight.
no setter
- startOfYear → FloatingDateTime
-
Returns January 1st of this date's year at midnight.
no setter
- timeZoneName → String
-
The time zone name.
no setterinherited
- timeZoneOffset → Duration
-
The time zone offset, which
is the difference between local time and UTC.
no setterinherited
- weekday → int
-
The day of the week monday..sunday.
no setterinherited
- weekNumber → int
-
Calculates week number from a date as per https://en.wikipedia.org/wiki/ISO_week_date#Calculation
no setter
- year → int
-
The year.
no setterinherited
- yearRange → FloatingDateTimeRange
-
Returns a half-open
[start, end)range covering this entire year.no setter
Methods
-
add(
Duration duration) → FloatingDateTime -
Adds a Duration to this FloatingDateTime and returns a new FloatingDateTime.
override
-
compareTo(
DateTime other) → int -
Compares this DateTime object to
other, returning zero if the values are equal.inherited -
copyWith(
{int? year, int? month, int? day, int? hour, int? minute, int? second, int? millisecond, int? microsecond}) → FloatingDateTime - Returns a new FloatingDateTime with the given fields replaced.
-
copyWith(
{int? year, int? month, int? day, int? hour, int? minute, int? second, int? millisecond, int? microsecond, bool? isUtc}) → DateTime -
Available on DateTime, provided by the DateTimeCopyWith extension
Creates a new DateTime from this one by updating individual properties. -
dayNameLocalized(
[Locale? locale]) → String -
Available on DateTime, provided by the DateTimeExtensions extension
Gets the day name in a specific locale. -
dayNameShortLocalized(
[Locale? locale]) → String -
Available on DateTime, provided by the DateTimeExtensions extension
Gets the abbreviated day name in a specific locale. -
difference(
DateTime other) → Duration -
Returns the Duration between this and
other.override -
endOfWeek(
{int firstDayOfWeek = DateTime.monday}) → FloatingDateTime - Returns midnight of the day after the last day of this date's week (exclusive upper bound).
-
forLocation(
{Location? location}) → DateTime -
Converts this FloatingDateTime to a DateTime for the specified
location. -
isAfter(
DateTime other) → bool -
Whether this DateTime occurs after
other.inherited -
isAtSameMomentAs(
DateTime other) → bool -
Whether this DateTime occurs at the same moment as
other.inherited -
isBefore(
DateTime other) → bool -
Whether this DateTime occurs before
other.inherited -
isSameDay(
FloatingDateTime date) → bool -
Checks if
datefalls on the same calendar day as this FloatingDateTime. -
isToday(
{Location? location, DateTime? now}) → bool -
Checks if this FloatingDateTime represents the current day in the specified
location. -
isWithin(
FloatingDateTimeRange range, {bool includeStart = true, bool includeEnd = false}) → bool - Checks if this FloatingDateTime occurs during the given FloatingDateTimeRange.
-
monthNameLocalized(
[Locale? locale]) → String -
Available on DateTime, provided by the DateTimeExtensions extension
Gets the month name in a specific locale. -
monthNameShortLocalized(
[Locale? locale]) → String -
Available on DateTime, provided by the DateTimeExtensions extension
Gets the abbreviated month name in a specific locale. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
startOfWeek(
{int firstDayOfWeek = DateTime.monday}) → FloatingDateTime - Returns midnight of the first day of this date's week.
-
subtract(
Duration duration) → FloatingDateTime -
Subtracts a Duration from this FloatingDateTime and returns a new FloatingDateTime.
override
-
timeLocalized(
{Locale? locale, bool use24HourFormat = false}) → String -
Available on DateTime, provided by the DateTimeExtensions extension
Gets the time of day in a specific locale. -
toIso8601String(
) → String -
Returns an ISO-8601 full-precision extended format representation.
inherited
-
toLocal(
) → DateTime -
Returns this DateTime value in the local time zone.
inherited
-
toString(
) → String -
Returns a human-readable string for this instance.
inherited
-
toUtc(
) → DateTime -
Returns this DateTime value in the UTC time zone.
inherited
-
weekRange(
{int firstDayOfWeek = DateTime.monday}) → FloatingDateTimeRange -
Returns a half-open
[start, end)range covering this entire week.
Operators
-
operator ==(
Object other) → bool -
Whether
otheris a DateTime at the same moment and in the same time zone (UTC or local).inherited
Static Methods
-
fromExternal(
DateTime dateTime, {Location? location}) → FloatingDateTime - Converts a DateTime or TZDateTime into an FloatingDateTime.