using System; using System.Text.RegularExpressions; namespace SourceGit.Git { /// /// Git user. /// public class User { private static readonly Regex FORMAT = new Regex(@"\w+ (.*) <([\w\.\-_]+@[\w\.\-_]+)> (\d{10}) [\+\-]\d+"); /// /// Name. /// public string Name { get; set; } = ""; /// /// Email. /// public string Email { get; set; } = ""; /// /// Operation time. /// public string Time { get; set; } = ""; /// /// Parse user from raw string. /// /// Raw string public void Parse(string data) { var match = FORMAT.Match(data); if (!match.Success) return; var time = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(int.Parse(match.Groups[3].Value)); Name = match.Groups[1].Value; Email = match.Groups[2].Value; Time = time.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"); } } }