private void ShowResults()
{
// This scenario illustrates time zone support in Windows.Globalization.Calendar class
// Displayed time zones in addition to the local time zone.
string[] timeZones = new[] { "UTC", "America/New_York", "Asia/Kolkata" };
// Store results here.
StringBuilder results = new StringBuilder();
// Create default Calendar object
Calendar calendar = new Calendar();
string localTimeZone = calendar.GetTimeZone();
// Show current time in local time zone
results.AppendLine("Current date and time:");
results.AppendLine(ReportCalendarData(calendar));
// Show current time in additional time zones
foreach (string timeZone in timeZones)
{
calendar.ChangeTimeZone(timeZone);
results.AppendLine(ReportCalendarData(calendar));
}
results.AppendLine();
// Change back to local time zone
calendar.ChangeTimeZone(localTimeZone);
// Show a time on 14th day of second month of next year.
// Note the effect of daylight saving time on the results.
results.AppendLine("Same time on 14th day of second month of next year:");
calendar.AddYears(1); calendar.Month = 2; calendar.Day = 14;
results.AppendLine(ReportCalendarData(calendar));
foreach (string timeZone in timeZones)
{
calendar.ChangeTimeZone(timeZone);
results.AppendLine(ReportCalendarData(calendar));
}
results.AppendLine();
// Change back to local time zone
calendar.ChangeTimeZone(localTimeZone);
// Show a time on 14th day of tenth month of next year.
// Note the effect of daylight saving time on the results.
results.AppendLine("Same time on 14th day of tenth month of next year:");
calendar.AddMonths(8);
results.AppendLine(ReportCalendarData(calendar));
foreach (string timeZone in timeZones)
{
calendar.ChangeTimeZone(timeZone);
results.AppendLine(ReportCalendarData(calendar));
}
results.AppendLine();
// Display the results
OutputTextBlock.Text = results.ToString();
}