本文整理汇总了C#中DateTimeOffset.ToSecondsSinceEpoch方法的典型用法代码示例。如果您正苦于以下问题:C# DateTimeOffset.ToSecondsSinceEpoch方法的具体用法?C# DateTimeOffset.ToSecondsSinceEpoch怎么用?C# DateTimeOffset.ToSecondsSinceEpoch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateTimeOffset
的用法示例。
在下文中一共展示了DateTimeOffset.ToSecondsSinceEpoch方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TruncateSubSeconds
protected static DateTimeOffset TruncateSubSeconds(DateTimeOffset dto)
{
int seconds = dto.ToSecondsSinceEpoch();
return Epoch.ToDateTimeOffset(seconds, (int) dto.Offset.TotalMinutes);
}
示例2: CreateSignature
private static IntPtr CreateSignature(string name, string email, DateTimeOffset when)
{
IntPtr signature;
int result = NativeMethods.git_signature_new(out signature, name, email, when.ToSecondsSinceEpoch(), (int)when.Offset.TotalMinutes);
Ensure.Success(result);
return signature;
}
示例3: UsTarHeader
public UsTarHeader(
string fileName,
string namePrefix,
DateTimeOffset lastModificationTime,
long size,
int mode,
string userId,
string groupId,
char typeflag,
string link,
string userName,
string groupName,
string deviceMajorNumber,
string deviceMinorNumber)
{
#region Length validations
if (userName.Length > 32)
{
throw new ArgumentException("ustar userName cannot be longer than 32 characters.", "userName");
}
if (groupName.Length > 32)
{
throw new ArgumentException("ustar groupName cannot be longer than 32 characters.", "groupName");
}
if (userId.Length > 7)
{
throw new ArgumentException("ustar userId cannot be longer than 7 characters.", "userId");
}
if (groupId.Length > 7)
{
throw new ArgumentException("ustar groupId cannot be longer than 7 characters.", "groupId");
}
if (deviceMajorNumber.Length > 7)
{
throw new ArgumentException("ustar deviceMajorNumber cannot be longer than 7 characters.", "deviceMajorNumber");
}
if (deviceMinorNumber.Length > 7)
{
throw new ArgumentException("ustar deviceMinorNumber cannot be longer than 7 characters.", "deviceMinorNumber");
}
if (link.Length > 100)
{
throw new ArgumentException("ustar link cannot be longer than 100 characters.", "link");
}
#endregion
this.mode = Convert.ToString(mode, 8).PadLeft(7, '0');
this.size = size;
unixTime = Convert.ToString(lastModificationTime.ToSecondsSinceEpoch(), 8).PadLeft(11, '0');
this.userId = userId.PadLeft(7, '0');
this.groupId = userId.PadLeft(7, '0');
this.userName = userName;
this.groupName = groupName;
this.typeflag = typeflag;
this.link = link;
this.deviceMajorNumber = deviceMajorNumber.PadLeft(7, '0');
this.deviceMinorNumber = deviceMinorNumber.PadLeft(7, '0');
this.fileName = fileName;
this.namePrefix = namePrefix;
}
示例4: Signature
/// <summary>
/// Initializes a new instance of the <see cref = "Signature" /> class.
/// </summary>
/// <param name = "name">The name.</param>
/// <param name = "email">The email.</param>
/// <param name = "when">The when.</param>
public Signature(string name, string email, DateTimeOffset when)
: this(NativeMethods.git_signature_new(name, email, when.ToSecondsSinceEpoch(), (int) when.Offset.TotalMinutes), false)
{
}