From 6926638822b1351b814e57799004e0ad12ec31a5 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Sun, 29 May 2011 16:48:47 +0100 Subject: [PATCH] repo: normalise timezones for the log --- SparkleLib/Git/SparkleRepoGit.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/SparkleLib/Git/SparkleRepoGit.cs b/SparkleLib/Git/SparkleRepoGit.cs index bb44c858..71433ff7 100644 --- a/SparkleLib/Git/SparkleRepoGit.cs +++ b/SparkleLib/Git/SparkleRepoGit.cs @@ -387,7 +387,7 @@ namespace SparkleLib { Regex non_merge_regex = new Regex (@"commit ([a-z0-9]{40})\n" + "Author: (.+) <(.+)>\n" + "Date: ([0-9]{4})-([0-9]{2})-([0-9]{2}) " + - "([0-9]{2}):([0-9]{2}):([0-9]{2}) .([0-9]{4})\n" + + "([0-9]{2}):([0-9]{2}):([0-9]{2}) (.[0-9]{4})\n" + "*", RegexOptions.Compiled); // TODO: Need to optimise for speed @@ -412,11 +412,24 @@ namespace SparkleLib { change_set.UserEmail = match.Groups [3].Value; change_set.IsMerge = is_merge_commit; + change_set.Timestamp = new DateTime (int.Parse (match.Groups [4].Value), int.Parse (match.Groups [5].Value), int.Parse (match.Groups [6].Value), int.Parse (match.Groups [7].Value), int.Parse (match.Groups [8].Value), int.Parse (match.Groups [9].Value)); + string time_zone = match.Groups [10].Value; + int hours_offset = int.Parse (time_zone.Substring (1, 2)); + + if (DateTime.Now.IsDaylightSavingTime ()) + hours_offset--; + + if (time_zone.StartsWith ("+")) + change_set.Timestamp.AddHours (hours_offset); + else + change_set.Timestamp.AddHours (hours_offset * -1); + + string [] entry_lines = log_entry.Split ("\n".ToCharArray ()); foreach (string entry_line in entry_lines) {