Example #1
0
 protected static DateTimeOffset TruncateSubSeconds(DateTimeOffset dto)
 {
     int seconds = dto.ToSecondsSinceEpoch();
     return Epoch.ToDateTimeOffset(seconds, (int) dto.Offset.TotalMinutes);
 }
Example #2
0
        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;
        }
Example #3
0
            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;
            }
Example #4
0
 /// <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)
 {
 }