title: DateTimeOffset to DateTime conversion - Data Loss
body: <p>When I convert a datetimeoffset value to a datetime value, is there any possibility for data loss. 
  From MSDN documentation, the conversion from datetimeoffset to datetime is mentioned as follows:</p>
  
  <blockquote>
    <p>The DateTime property is most commonly used to perform DateTimeOffset
    to DateTime conversion. However, it returns a DateTime value whose
    Kind property is Unspecified. This means that any information about
    the DateTimeOffset value's relationship to UTC is lost by the
    conversion when the DateTime property is used.</p>
  </blockquote>
  
  <p>To indicate that a converted DateTime value is the UTC time, you can retrieve the value of the DateTimeOffset.UtcDateTime property. It differs from the DateTime property in two ways:</p>
  
  <p>It returns a DateTime value whose Kind property is Utc.
  If the Offset property value does not equal TimeSpan.Zero, it converts the time to UTC.</p>
  
  <p>I see the following method to convert datetime offset to datetime:</p>
  
  <pre><code>static DateTime ConvertFromDateTimeOffset(DateTimeOffset dateTime)
  {
     if (dateTime.Offset.Equals(TimeSpan.Zero))
        return dateTime.UtcDateTime;
     else if (dateTime.Offset.Equals(TimeZoneInfo.Local.GetUtcOffset(dateTime.DateTime)))
        return DateTime.SpecifyKind(dateTime.DateTime, DateTimeKind.Local);
     else
        return dateTime.DateTime;   
  }
  </code></pre>
  
  <p>Now in our system we are converting datetimeoffset to datetime in the above way. Later we want to convert the datetime back to datetimeoffset.</p>
  
  <p>As an example:</p>
  
  <pre><code>DateTime dt = ConvertFromDateTimeOffset(datetimeOffset);
  DateTimeOffset dofsetnew = new DateTimeOffset(dt);
  </code></pre>
  
  <p>My question is whether under any circumstances datetimeOffset and dofsetnew be different ? If so then conversion would be loss data.</p>