InternalDateTime class

A DateTime subclass that stores date/time components as-is via DateTime.utc, bypassing implicit timezone conversions.

Not a real UTC instant — the UTC flag is only used to prevent Dart from applying local-timezone adjustments. This makes arithmetic (e.g. add, subtract) DST-safe and keeps display values stable across timezones.

Use fromExternal to convert a wall-clock DateTime or TZDateTime into an InternalDateTime, and forLocation to convert back.

Inheritance
Available extensions

Constructors

InternalDateTime(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 InternalDateTime instance.
InternalDateTime.fromDateTime(DateTime dateTime)
Creates a InternalDateTime from an existing DateTime.

Properties

day int
The day of the month [1..31].
no setterinherited
dayNameEnglish String

Available on DateTime, provided by the DateTimeExtensions extension

Gets the day name in English (backwards compatibility).
no setter
dayRange InternalDateTimeRange
Returns a half-open [start, end) range covering this entire day.
no setter
endOfDay InternalDateTime
Returns midnight (00:00:00) of the next day (exclusive upper bound).
no setter
endOfMonth InternalDateTime
Returns the first day of the next month at midnight (exclusive upper bound).
no setter
endOfYear InternalDateTime
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
monthNameEnglish String

Available on DateTime, provided by the DateTimeExtensions extension

Gets the month name in English (backwards compatibility).
no setter
monthRange InternalDateTimeRange
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 InternalDateTime
Returns midnight (00:00:00) of this date.
no setter
startOfMonth InternalDateTime
Returns the first day of this date's month at midnight.
no setter
startOfYear InternalDateTime
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 InternalDateTimeRange
Returns a half-open [start, end) range covering this entire year.
no setter

Methods

add(Duration duration) InternalDateTime
Adds a Duration to this InternalDateTime and returns a new InternalDateTime.
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}) InternalDateTime
Returns a new InternalDateTime 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([dynamic locale]) String

Available on DateTime, provided by the DateTimeExtensions extension

Gets the day name in a specific locale.
dayNameShortLocalized([dynamic 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}) InternalDateTime
Returns midnight of the day after the last day of this date's week (exclusive upper bound).
forLocation({Location? location}) DateTime
Converts this InternalDateTime 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(InternalDateTime date) bool
Checks if date falls on the same calendar day as this InternalDateTime.
isToday({Location? location, DateTime? now}) bool
Checks if this InternalDateTime represents the current day in the specified location.
isWithin(InternalDateTimeRange dateTimeRange, {bool includeStart = true, bool includeEnd = false}) bool
Checks if this InternalDateTime occurs during the given InternalDateTimeRange.
monthNameLocalized([dynamic locale]) String

Available on DateTime, provided by the DateTimeExtensions extension

Gets the month name in a specific locale.
monthNameShortLocalized([dynamic 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}) InternalDateTime
Returns midnight of the first day of this date's week.
subtract(Duration duration) InternalDateTime
Subtracts a Duration from this InternalDateTime and returns a new InternalDateTime.
override
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}) InternalDateTimeRange
Returns a half-open [start, end) range covering this entire week.

Operators

operator ==(Object other) bool
Whether other is a DateTime at the same moment and in the same time zone (UTC or local).
inherited

Static Methods

fromExternal(DateTime dateTime, {Location? location}) InternalDateTime
Converts a DateTime or TZDateTime into an InternalDateTime.