stringToTimeZoneOffset function

int? stringToTimeZoneOffset(
  1. String? offset
)

Implementation

int? stringToTimeZoneOffset(String? offset) {
  if (offset == null) {
    return null;
  } else {
    bool? positive;
    if (offset.startsWith('+')) {
      positive = true;
      offset = offset.substring(1);
    } else if (offset.startsWith('-')) {
      positive = false;
      offset = offset.substring(1);
    }
    positive ??= true;
    return (int.tryParse(offset.split(':').first) ?? 0) * (positive ? 1 : -1);
  }
}