parse static method
Implementation
static VTimezone parse(String vtimezoneString) {
final lines = vtimezoneString.split('\n');
String? tzid;
Duration? standardOffset;
Duration? daylightOffset;
DateTime? standardStart;
DateTime? daylightStart;
for (var line in lines) {
final parts = line.split(':');
if (parts.length < 2) continue;
final key = parts[0];
final value = parts.getRange(1, parts.length).join(':');
switch (key) {
case 'TZID':
tzid = value;
break;
case 'TZOFFSETFROM':
standardOffset = parseOffsetToDuration(value);
break;
case 'TZOFFSETTO':
daylightOffset = parseOffsetToDuration(value);
break;
case 'DTSTART':
if (line.contains("STANDARD")) {
standardStart = DateTime.parse(value.replaceAll('Z', ''));
} else if (line.contains("DAYLIGHT")) {
daylightStart = DateTime.parse(value.replaceAll('Z', ''));
}
break;
}
}
return VTimezone(
tzid: tzid ?? '',
standardOffset: standardOffset,
daylightOffset: daylightOffset,
standardStart: standardStart,
daylightStart: daylightStart,
);
}