resolveCronTimeZone function
Returns the tz.Location of timeZone (an IANA name, like
Europe/Paris). null, empty or UTC: tz.UTC.
A name not in the database loaded (e.g. an alias, not in the timezone
default database) loads the full database (a superset: the names already
resolved, here or by the application, keep resolving) and is tried again.
Throws an ArgumentError for an unknown time zone.
Implementation
tz.Location resolveCronTimeZone(String? timeZone) {
timeZone = timeZone?.trim();
if (timeZone == null ||
timeZone.isEmpty ||
timeZone.toUpperCase() == 'UTC' ||
timeZone.toUpperCase() == 'Z') {
return tz.UTC;
}
initializeCronTimeZones();
try {
return tz.getLocation(timeZone);
} on tz.LocationNotFoundException {
if (!_fullDatabaseLoaded) {
_loadFullDatabase();
return resolveCronTimeZone(timeZone);
}
throw ArgumentError.value(timeZone, 'timeZone', 'Unknown time zone');
}
}