using System;
public class DateTimeOffsetConversion
{
private static DateTimeOffset sourceTime;
public static void Main()
{
DateTimeOffset targetTime;
sourceTime = new DateTimeOffset(2010, 9, 1, 9, 30, 0, new TimeSpan(-5, 0, 0));
targetTime = sourceTime.ToOffset(TimeSpan.Zero);
ShowDateAndTimeInfo(targetTime);
}
private static void ShowDateAndTimeInfo(DateTimeOffset newTime)
{
Console.WriteLine("{0} converts to {1}", sourceTime, newTime);
Console.WriteLine("{0} and {1} are equal: {2}", sourceTime, newTime, sourceTime.Equals(newTime));
Console.WriteLine("{0} and {1} are identical: {2}", sourceTime, newTime, sourceTime.EqualsExact(newTime));
}
}