using System;
using System.Globalization;
public class Example
{
public static void Main()
{
DateTimeOffset localTime, otherTime, universalTime;
// Define local time in local time zone
localTime = new DateTimeOffset(new DateTime(2007, 6, 15, 12, 0, 0));
Console.WriteLine("Local time: {0}", localTime);
// Convert local time to offset 0 and assign to otherTime
otherTime = localTime.ToOffset(TimeSpan.Zero);
Console.WriteLine("Other time: {0}", otherTime);
Console.WriteLine("{0} = {1}: {2}", localTime, otherTime, localTime.Equals(otherTime));
Console.WriteLine("{0} exactly equals {1}: {2}", localTime, otherTime, localTime.EqualsExact(otherTime));
// Convert other time to UTC
universalTime = localTime.ToUniversalTime();
Console.WriteLine("Universal time: {0}", universalTime);
Console.WriteLine("{0} = {1}: {2}", otherTime, universalTime, universalTime.Equals(otherTime));
Console.WriteLine("{0} exactly equals {1}: {2}", otherTime, universalTime, universalTime.EqualsExact(otherTime));
}
}