Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
Libgit2sharp
提交
1267c641
L
Libgit2sharp
项目概览
jobily
/
Libgit2sharp
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
Libgit2sharp
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1267c641
编写于
12月 08, 2010
作者:
N
nulltoken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added EpochHelper class to ease unix time/DateTimeOffset conversion.
上级
b6ea4b1f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
44 addition
and
0 deletion
+44
-0
libgit2sharp.Tests/EpochHelperFixture.cs
libgit2sharp.Tests/EpochHelperFixture.cs
+27
-0
libgit2sharp.Tests/libgit2sharp.Tests.csproj
libgit2sharp.Tests/libgit2sharp.Tests.csproj
+1
-0
libgit2sharp/EpochHelper.cs
libgit2sharp/EpochHelper.cs
+15
-0
libgit2sharp/libgit2sharp.csproj
libgit2sharp/libgit2sharp.csproj
+1
-0
未找到文件。
libgit2sharp.Tests/EpochHelperFixture.cs
0 → 100644
浏览文件 @
1267c641
using
System
;
using
NUnit.Framework
;
namespace
libgit2sharp.Tests
{
[
TestFixture
]
public
class
EpochHelperFixture
{
[
TestCase
(
0
)]
[
TestCase
(
17
)]
public
void
ToDateDateTimeOffset_ShouldReturnAUtcBasedDateTimeOffset
(
Int32
secondsSinceEpoch
)
{
DateTimeOffset
when
=
EpochHelper
.
ToDateTimeOffset
(
secondsSinceEpoch
);
Assert
.
AreEqual
(
TimeSpan
.
Zero
,
when
.
Offset
);
Assert
.
AreEqual
(
DateTimeKind
.
Utc
,
when
.
UtcDateTime
.
Kind
);
}
[
TestCase
(
1291801952
,
"Wed, 08 Dec 2010 09:52:32 GMT"
)]
[
TestCase
(
1234567890
,
"Fri, 13 Feb 2009 23:31:30 GMT"
)]
public
void
ToDateDateTimeOffset_ShouldCorrectlyConvert
(
Int32
secondsSinceEpoch
,
string
expected
)
{
DateTimeOffset
when
=
EpochHelper
.
ToDateTimeOffset
(
secondsSinceEpoch
);
var
expectedDate
=
DateTimeOffset
.
Parse
(
expected
);
Assert
.
AreEqual
(
expectedDate
,
when
);
}
}
}
libgit2sharp.Tests/libgit2sharp.Tests.csproj
浏览文件 @
1267c641
...
...
@@ -43,6 +43,7 @@
<Reference
Include=
"System.Xml"
/>
</ItemGroup>
<ItemGroup>
<Compile
Include=
"EpochHelperFixture.cs"
/>
<Compile
Include=
"RepositoryFixtures.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
</ItemGroup>
...
...
libgit2sharp/EpochHelper.cs
0 → 100644
浏览文件 @
1267c641
using
System
;
namespace
libgit2sharp
{
public
static
class
EpochHelper
{
public
static
readonly
long
EpochTicks
=
new
DateTimeOffset
(
1970
,
1
,
1
,
0
,
0
,
0
,
TimeSpan
.
Zero
).
Ticks
;
public
static
DateTimeOffset
ToDateTimeOffset
(
Int32
secondsSinceEpoch
)
{
long
ticks
=
secondsSinceEpoch
*
TimeSpan
.
TicksPerSecond
+
EpochTicks
;
return
new
DateTimeOffset
(
ticks
,
TimeSpan
.
Zero
);
}
}
}
\ No newline at end of file
libgit2sharp/libgit2sharp.csproj
浏览文件 @
1267c641
...
...
@@ -42,6 +42,7 @@
<ItemGroup>
<Compile
Include=
"Blob.cs"
/>
<Compile
Include=
"Commit.cs"
/>
<Compile
Include=
"EpochHelper.cs"
/>
<Compile
Include=
"ObjectId.cs"
/>
<Compile
Include=
"Person.cs"
/>
<Compile
Include=
"RawObject.cs"
/>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录