parse static method
Parse a raw timezone string (e.g. "UTC+05:30" → "+05:30", "UTC" → "+00:00").
Throws FormatException if the normalized offset is not a valid ±HH:MM string.
Note: fromJson handles Map-based deserialization; this method handles
the raw UTC string list stored in Country.timeZones.
Implementation
static TimeZone parse(String raw) {
if (raw == 'UTC') return const TimeZone(offset: '+00:00');
final normalized = raw.startsWith('UTC') ? raw.substring(3) : raw;
// Bare "00:00" is valid UTC zero offset — normalise to "+00:00".
if (normalized == '00:00') return const TimeZone(offset: '+00:00');
if (!_validOffset.hasMatch(normalized)) {
throw FormatException('Invalid UTC offset: "$raw"');
}
return TimeZone(offset: normalized);
}