HijriDateTime class

A date and time in Saudi Arabia's Umm al-Qura calendar.

Umm al-Qura is a published, data-backed calendar. It is not the arithmetic (civil/tabular) Islamic calendar, and it must not be extrapolated with a repeating leap-year formula. This implementation therefore supports only the verified data range AH minimumYear through AH maximumYear. Unsupported dates throw RangeError instead of silently changing calendar systems.

Instances retain the exact native DateTime instant internally. Calendar fields such as year, month, and day are exposed in Umm al-Qura, while epoch values, equality, time-zone data, and comparisons use the true Gregorian instant.

Inheritance
Implemented types
Available extensions

Constructors

HijriDateTime(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 local Umm al-Qura date, normalizing overflowing components in the same style as DateTime.new.
factory
HijriDateTime.fromDateTime(DateTime dateTime)
Converts a native Gregorian dateTime to Umm al-Qura without losing its instant, precision, or UTC/local representation.
factory
HijriDateTime.fromMicrosecondsSinceEpoch(int microsecondsSinceEpoch, {bool isUtc = false})
factory
HijriDateTime.fromMillisecondsSinceEpoch(int millisecondsSinceEpoch, {bool isUtc = false})
factory
HijriDateTime.fromSecondsSinceEpoch(int secondsSinceEpoch, {bool isUtc = false})
factory
HijriDateTime.now()
The current local date and time in Umm al-Qura.
factory
HijriDateTime.parse(String formattedString)
Parses a Hijri ISO-8601-like string.
factory
HijriDateTime.timestamp()
The current UTC date and time in Umm al-Qura.
factory
HijriDateTime.utc(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 UTC Umm al-Qura date, normalizing overflowing components in the same style as DateTime.utc.
factory

Properties

day → int
The day of the month [1..31].
final
dayOfYear → int
One-based day within the Umm al-Qura year.
no setteroverride
hashCode → int
The hash code for this object.
no setterinherited
hasOfficialCalendarData → bool
Whether this year uses the published Umm al-Qura calendar table.
no setter
hour → int
The hour of the day, expressed as in a 24-hour clock [0..23].
final
isLeapYear → bool
Whether this Umm al-Qura year contains 355 days.
no setteroverride
isUtc → bool
True if this DateTime is set to UTC time.
finalinherited
julianDay → int
Gregorian Julian day number for this calendar date.
no setteroverride
microsecond → int
The microsecond [0...999].
final
microsecondsSinceEpoch → int
The number of microseconds since the "Unix epoch" 1970-01-01T00:00:00Z (UTC).
no setterinherited
millisecond → int
The millisecond [0...999].
final
millisecondsSinceEpoch → int
The number of milliseconds since the "Unix epoch" 1970-01-01T00:00:00Z (UTC).
no setterinherited
minute → int
The minute [0...59].
final
month → int
The month [1..12].
final
monthLength → int
Official length of this Umm al-Qura month.
no setteroverride
name → String
The calendar name.
no setteroverride
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
second → int
The second [0...59].
final
secondsSinceEpoch → int
Unix seconds, rounded down directly from microsecondsSinceEpoch.
no setteroverride
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
Weekday using DateTime.monday through DateTime.sunday.
no setteroverride
year → int
The year.
final
yearLength → int
Number of days in this Umm al-Qura year.
no setter

Methods

add(Duration duration) → HijriDateTime
Adds an exact duration and converts the resulting instant to Umm al-Qura.
override
compareTo(DateTime other) → int
Compares this DateTime object to other, returning zero if the values are equal.
override
copyWith({int? year, int? month, int? day, int? hour, int? minute, int? second, int? millisecond, int? microsecond, bool? isUtc}) → HijriDateTime
Creates a copy with selected Umm al-Qura wall-clock 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.
difference(DateTime other) → Duration
Returns a Duration with the difference when subtracting other from this DateTime.
override
isAfter(DateTime other) → bool
Whether this DateTime occurs after other.
override
isAtSameMomentAs(DateTime other) → bool
Whether this DateTime occurs at the same moment as other.
override
isBefore(DateTime other) → bool
Whether this DateTime occurs before other.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
subtract(Duration duration) → HijriDateTime
Subtracts an exact duration and converts the resulting instant to Umm al-Qura.
override
toDateTime() → DateTime
Converts this value to a native Gregorian DateTime.
override
toIso8601String() → String
Returns an ISO-like string with Umm al-Qura fields, not Gregorian.
override
toLocal() → HijriDateTime
Converts this instant to local time.
override
toString() → String
Returns a human-readable string for this instance.
override
toUtc() → HijriDateTime
Converts this instant to UTC.
override

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 Properties

maximumGregorianDate → DateTime
The last supported Gregorian calendar date, in UTC.
no setter
minimumGregorianDate → DateTime
The first supported Gregorian calendar date, in UTC.
no setter

Static Methods

daysInMonth(int year, int month) → int
Returns the official Umm al-Qura length of month in year.
isSupportedDateTime(DateTime dateTime) → bool
Whether the Gregorian wall date of dateTime is available in this implementation's Umm al-Qura data.
isValidDate(int year, int month, int day) → bool
Whether year, month, and day form a strict (non-normalized) supported Umm al-Qura date.
tryParse(String formattedString) → HijriDateTime?
Parses formattedString, returning null for invalid or unsupported dates.
override

Constants

daysPerWeek → const int
dhuhijjah → const int
dhuqidah → const int
friday → const int
jumada1 → const int
jumada2 → const int
maximumOfficialYear → const int
Last Hijri year covered by the published Umm al-Qura table.
maximumYear → const int
Last supported Umm al-Qura year.
minimumOfficialYear → const int
First Hijri year covered by the published Umm al-Qura table.
minimumYear → const int
First supported Umm al-Qura year.
monday → const int
monthsPerYear → const int
muharram → const int
rabi1 → const int
rabi2 → const int
rajab → const int
ramadan → const int
safar → const int
saturday → const int
shaban → const int
shawwal → const int
sunday → const int
thursday → const int
tuesday → const int
wednesday → const int