Просмотр исходного кода

SMB_DATE, SMB_TIME, UTime: Set DateTimeKind to Local

Tal Aloni 7 лет назад
Родитель
Сommit
6d17dbabd6
2 измененных файлов с 3 добавлено и 2 удалено
  1. 2 1
      SMBLibrary/SMB1/SMB1Helper.cs
  2. 1 1
      SMBLibrary/SMB1/UTimeHelper.cs

+ 2 - 1
SMBLibrary/SMB1/SMB1Helper.cs

@@ -46,7 +46,8 @@ namespace SMBLibrary.SMB1
             int year = ((value & 0xFE00) >> 9) + 1980;
             int month = ((value & 0x01E0) >> 5);
             int day = (value & 0x001F);
-            return new DateTime(year, month, day);
+            // SMB_DATE & SMB_TIME are represented in the local time zone of the server
+            return new DateTime(year, month, day, 0, 0, 0, DateTimeKind.Local);
         }
 
         public static void WriteSMBDate(byte[] buffer, int offset, DateTime date)

+ 1 - 1
SMBLibrary/SMB1/UTimeHelper.cs

@@ -16,7 +16,7 @@ namespace SMBLibrary.SMB1
     /// </summary>
     public class UTimeHelper
     {
-        public static readonly DateTime MinUTimeValue = new DateTime(1970, 1, 1);
+        public static readonly DateTime MinUTimeValue = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Local);
 
         public static DateTime ReadUTime(byte[] buffer, int offset)
         {