System.IO.Compression.ZipHelper.DosTimeToDateTime C# (CSharp) Méthode

DosTimeToDateTime() static private méthode

static private DosTimeToDateTime ( uint dateTime ) : DateTime
dateTime uint
Résultat DateTime
        internal static DateTime DosTimeToDateTime(uint dateTime)
        {
            // do the bit shift as unsigned because the fields are unsigned, but
            // we can safely convert to int, because they won't be too big
            int year = (int)(ValidZipDate_YearMin + (dateTime >> 25));
            int month = (int)((dateTime >> 21) & 0xF);
            int day = (int)((dateTime >> 16) & 0x1F);
            int hour = (int)((dateTime >> 11) & 0x1F);
            int minute = (int)((dateTime >> 5) & 0x3F);
            int second = (int)((dateTime & 0x001F) * 2);       // only 5 bits for second, so we only have a granularity of 2 sec. 

            try
            {
                return new System.DateTime(year, month, day, hour, minute, second, 0);
            }
            catch (ArgumentOutOfRangeException)
            {
                return s_invalidDateIndicator;
            }
            catch (ArgumentException)
            {
                return s_invalidDateIndicator;
            }
        }

Usage Example

Exemple #1
0
 internal ZipArchiveEntry(ZipArchive archive, ZipCentralDirectoryFileHeader cd)
 {
     this._archive                      = archive;
     this._originallyInArchive          = true;
     this._diskNumberStart              = cd.DiskNumberStart;
     this._versionToExtract             = (ZipVersionNeededValues)cd.VersionNeededToExtract;
     this._generalPurposeBitFlag        = (ZipArchiveEntry.BitFlagValues)cd.GeneralPurposeBitFlag;
     this.CompressionMethod             = (ZipArchiveEntry.CompressionMethodValues)cd.CompressionMethod;
     this._lastModified                 = new DateTimeOffset(ZipHelper.DosTimeToDateTime(cd.LastModified));
     this._compressedSize               = cd.CompressedSize;
     this._uncompressedSize             = cd.UncompressedSize;
     this._externalFileAttr             = cd.ExternalFileAttributes;
     this._offsetOfLocalHeader          = cd.RelativeOffsetOfLocalHeader;
     this._storedOffsetOfCompressedData = null;
     this._crc32                  = cd.Crc32;
     this._compressedBytes        = null;
     this._storedUncompressedData = null;
     this._currentlyOpenForWrite  = false;
     this._everOpenedForWrite     = false;
     this._outstandingWriteStream = null;
     this.FullName                = this.DecodeEntryName(cd.Filename);
     this._lhUnknownExtraFields   = null;
     this._cdUnknownExtraFields   = cd.ExtraFields;
     this._fileComment            = cd.FileComment;
     this._compressionLevel       = null;
 }
All Usage Examples Of System.IO.Compression.ZipHelper::DosTimeToDateTime