parse static method

GitAuthor? parse(
  1. String input
)

Implementation

static GitAuthor? parse(String input) {
  // Regex " AuthorName <Email>  timestamp timeOffset"
  var pattern = RegExp(r'(.*) <(.*)> (\d+) ([+\-]\d\d\d\d)');
  var match = pattern.allMatches(input).toList();
  if (match.isEmpty) {
    return null;
  }

  var timestamp = (int.parse(match[0].group(3)!)) * 1000;
  return GitAuthor(
    name: match[0].group(1)!,
    email: match[0].group(2)!,
    date: DateTime.fromMillisecondsSinceEpoch(timestamp, isUtc: true),
    timezoneOffset: int.parse(match[0].group(4)!),
  );
}