private GuardEvent Parse(string eventLine) { const string pattern = @"\[(.*)\] (.*)"; const string timeStampPattern = @"yyyy-MM-dd HH:mm"; var regex = new Regex(pattern); var match = regex.Match(eventLine); if (!match.Success) { return(null); } var exactTimeStamp = DateTime.ParseExact(match.Groups[1].Value, timeStampPattern, CultureInfo.InvariantCulture); var effectiveTimeStamp = exactTimeStamp; if (effectiveTimeStamp.Hour != 0) { effectiveTimeStamp.AddDays(1); effectiveTimeStamp = exactTimeStamp.Date; } var guardEvent = new GuardEvent { actualTimeStamp = exactTimeStamp, effectiveTimeStamp = effectiveTimeStamp, description = match.Groups[2].Value }; return(guardEvent); }
public int CompareTo(GuardEvent other) { if (other == null) { return(1); } if (year != other.year) { return(year.CompareTo(other.year)); } if (month != other.month) { return(month.CompareTo(other.month)); } if (day != other.day) { return(day.CompareTo(other.day)); } if (hour != other.hour) { return(hour.CompareTo(other.hour)); } return(minute.CompareTo(other.minute)); }