当前位置: 首页>>代码示例>>C#>>正文


C# DateTimeOffset.ToSecondsSinceEpoch方法代码示例

本文整理汇总了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);
 }
开发者ID:JenekX,项目名称:libgit2sharp,代码行数:5,代码来源:BaseFixture.cs

示例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;
        }
开发者ID:sc68cal,项目名称:libgit2sharp,代码行数:8,代码来源:Signature.cs

示例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;
            }
开发者ID:Bacem,项目名称:libgit2sharp,代码行数:63,代码来源:TarWriter.cs

示例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)
 {
 }
开发者ID:henon,项目名称:libgit2sharp,代码行数:10,代码来源:Signature.cs


注:本文中的DateTimeOffset.ToSecondsSinceEpoch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。