From 138ac02a34030dc3359eefee3025dc3e0b4b5954 Mon Sep 17 00:00:00 2001 From: nulltoken Date: Thu, 9 Dec 2010 16:10:26 +0100 Subject: [PATCH] Renamed EpochHelper to Epoch. --- .../{EpochHelperFixture.cs => EpochFixture.cs} | 6 +++--- libgit2sharp.Tests/RepositoryFixtures.cs | 2 +- libgit2sharp.Tests/libgit2sharp.Tests.csproj | 2 +- libgit2sharp/Epoch.cs | 14 ++++++++++++++ libgit2sharp/EpochHelper.cs | 14 -------------- libgit2sharp/Wrapper/git_commit.cs | 2 +- libgit2sharp/Wrapper/git_person.cs | 2 +- libgit2sharp/libgit2sharp.csproj | 2 +- 8 files changed, 22 insertions(+), 22 deletions(-) rename libgit2sharp.Tests/{EpochHelperFixture.cs => EpochFixture.cs} (78%) create mode 100644 libgit2sharp/Epoch.cs delete mode 100644 libgit2sharp/EpochHelper.cs diff --git a/libgit2sharp.Tests/EpochHelperFixture.cs b/libgit2sharp.Tests/EpochFixture.cs similarity index 78% rename from libgit2sharp.Tests/EpochHelperFixture.cs rename to libgit2sharp.Tests/EpochFixture.cs index 1ef27e75..3ed2c569 100644 --- a/libgit2sharp.Tests/EpochHelperFixture.cs +++ b/libgit2sharp.Tests/EpochFixture.cs @@ -4,13 +4,13 @@ namespace libgit2sharp.Tests { [TestFixture] - public class EpochHelperFixture + public class EpochFixture { [TestCase(0)] [TestCase(17)] public void ToDateDateTimeOffset_ShouldReturnAUtcBasedDateTimeOffset(Int32 secondsSinceEpoch) { - DateTimeOffset when = EpochHelper.ToDateTimeOffset(secondsSinceEpoch); + DateTimeOffset when = Epoch.ToDateTimeOffset(secondsSinceEpoch); Assert.AreEqual(TimeSpan.Zero, when.Offset); Assert.AreEqual(DateTimeKind.Utc, when.UtcDateTime.Kind); } @@ -20,7 +20,7 @@ public void ToDateDateTimeOffset_ShouldReturnAUtcBasedDateTimeOffset(Int32 secon [TestCase(1288114383, "Tue, 26 Oct 2010 17:33:03 GMT")] public void ToDateDateTimeOffset_ShouldCorrectlyConvert(Int32 secondsSinceEpoch, string expected) { - DateTimeOffset when = EpochHelper.ToDateTimeOffset(secondsSinceEpoch); + DateTimeOffset when = Epoch.ToDateTimeOffset(secondsSinceEpoch); var expectedDate = DateTimeOffset.Parse(expected); Assert.AreEqual(expectedDate, when); } diff --git a/libgit2sharp.Tests/RepositoryFixtures.cs b/libgit2sharp.Tests/RepositoryFixtures.cs index 32fe58b2..2cbbcc75 100644 --- a/libgit2sharp.Tests/RepositoryFixtures.cs +++ b/libgit2sharp.Tests/RepositoryFixtures.cs @@ -155,7 +155,7 @@ private static void AssertTag0c37a53(string objectId, Tag tag) Assert.AreEqual("v1.0", tag.Name); Assert.AreEqual("schacon@gmail.com", tag.Tagger.Email); Assert.AreEqual("test tag message\n", tag.Message); - Assert.AreEqual(EpochHelper.ToDateTimeOffset(1288114383), tag.Tagger.Time); + Assert.AreEqual(Epoch.ToDateTimeOffset(1288114383), tag.Tagger.Time); Assert.AreEqual("5b5b025afb0b4c913b4c338a42934a3863bf3644", tag.Target.Id); } diff --git a/libgit2sharp.Tests/libgit2sharp.Tests.csproj b/libgit2sharp.Tests/libgit2sharp.Tests.csproj index fa01a6a2..a3ac39f1 100644 --- a/libgit2sharp.Tests/libgit2sharp.Tests.csproj +++ b/libgit2sharp.Tests/libgit2sharp.Tests.csproj @@ -43,7 +43,7 @@ - + diff --git a/libgit2sharp/Epoch.cs b/libgit2sharp/Epoch.cs new file mode 100644 index 00000000..1fecac0e --- /dev/null +++ b/libgit2sharp/Epoch.cs @@ -0,0 +1,14 @@ +using System; + +namespace libgit2sharp +{ + public static class Epoch + { + private static readonly DateTimeOffset EpochDateTimeOffset = new DateTimeOffset(1970, 1, 1, 0, 0, 0, TimeSpan.Zero); + + public static DateTimeOffset ToDateTimeOffset(Int32 secondsSinceEpoch) + { + return EpochDateTimeOffset.AddSeconds(secondsSinceEpoch); + } + } +} \ No newline at end of file diff --git a/libgit2sharp/EpochHelper.cs b/libgit2sharp/EpochHelper.cs deleted file mode 100644 index d6b7f1e1..00000000 --- a/libgit2sharp/EpochHelper.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; - -namespace libgit2sharp -{ - public static class EpochHelper - { - public static readonly DateTimeOffset Epoch = new DateTimeOffset(1970, 1, 1, 0, 0, 0, TimeSpan.Zero); - - public static DateTimeOffset ToDateTimeOffset(Int32 secondsSinceEpoch) - { - return Epoch.AddSeconds(secondsSinceEpoch); - } - } -} \ No newline at end of file diff --git a/libgit2sharp/Wrapper/git_commit.cs b/libgit2sharp/Wrapper/git_commit.cs index 20da4f49..cb7117db 100644 --- a/libgit2sharp/Wrapper/git_commit.cs +++ b/libgit2sharp/Wrapper/git_commit.cs @@ -36,7 +36,7 @@ internal Commit Build() var gitTree = (git_tree)Marshal.PtrToStructure(tree, typeof(git_tree)); Tree commitTree = gitTree.Build(); - return new Commit(ObjectId.ToString(commit.id.id), commitAuthor, commitCommitter, EpochHelper.ToDateTimeOffset((int)time), message, message_short, commitTree); + return new Commit(ObjectId.ToString(commit.id.id), commitAuthor, commitCommitter, Epoch.ToDateTimeOffset((int)time), message, message_short, commitTree); } } } diff --git a/libgit2sharp/Wrapper/git_person.cs b/libgit2sharp/Wrapper/git_person.cs index 46f8660f..4f93626a 100644 --- a/libgit2sharp/Wrapper/git_person.cs +++ b/libgit2sharp/Wrapper/git_person.cs @@ -16,7 +16,7 @@ internal struct git_person internal Person Build() { - return new Person(name, email, EpochHelper.ToDateTimeOffset((int)time)); + return new Person(name, email, Epoch.ToDateTimeOffset((int)time)); } } } \ No newline at end of file diff --git a/libgit2sharp/libgit2sharp.csproj b/libgit2sharp/libgit2sharp.csproj index 4fc2011f..2756db1e 100644 --- a/libgit2sharp/libgit2sharp.csproj +++ b/libgit2sharp/libgit2sharp.csproj @@ -42,7 +42,7 @@ - + -- GitLab