[smuxi/stable] Common: de-serialize DateTime ticks in UTC (refs: #1058)



commit 4cdc94d5b294f1df31b35f8344f5ca362e041cf4
Author: Mirco Bauer <meebey meebey net>
Date:   Tue Jun 16 23:43:22 2015 +0200

    Common: de-serialize DateTime ticks in UTC (refs: #1058)
    
    DateTime ticks are by definition from a specified point of time in UTC [0]. The
    DateTime ctor that takes tick as Int64 initializes the DateTime object though as
    DateTimeKind.Unspecified leading to unexpected behavior when the time is
    transformed to UTC or local time.
    
     [0]: https://msdn.microsoft.com/en-us/library/system.datetime.ticks(v=vs.110).aspx

 src/Common/FastSerializer.cs |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/src/Common/FastSerializer.cs b/src/Common/FastSerializer.cs
index e1a49fb..903e4f7 100644
--- a/src/Common/FastSerializer.cs
+++ b/src/Common/FastSerializer.cs
@@ -331,7 +331,7 @@ namespace Smuxi.Common
         /// <summary> Reads a DateTime from the buffer. </summary>
         public DateTime ReadDateTime()
         {
-            return new DateTime(ReadInt64());
+            return new DateTime(ReadInt64(), DateTimeKind.Utc);
         }
 
         public IList ReadList()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]