Skip to content

Instantly share code, notes, and snippets.

@TomKearney
Last active March 26, 2018 11:05
Show Gist options
  • Select an option

  • Save TomKearney/a0483d09bf15b027dad74db078fe5196 to your computer and use it in GitHub Desktop.

Select an option

Save TomKearney/a0483d09bf15b027dad74db078fe5196 to your computer and use it in GitHub Desktop.
Determine Calgary market open hours in different timezones
Console.WriteLine("NOW: " + DateTime.UtcNow);
var timesOfYear = new List<Tuple<string, DateTime>>
{
Tuple.Create("Today (now)", DateTime.UtcNow),
Tuple.Create("Calgary Summer", new DateTime(2018, 6, 27, 14, 30, 0).ToUniversalTime()),
Tuple.Create("Calgary Winter", new DateTime(2018, 11, 21, 14, 00, 0).ToUniversalTime()),
Tuple.Create("In between DST", new DateTime(2018, 3, 19, 14, 30, 0).ToUniversalTime())
};
foreach (var timeOfYear in timesOfYear)
{
Console.WriteLine($"\r\n==={timeOfYear.Item1} (UTC: {timeOfYear.Item2})===");
DateTime calgaryTime = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(timeOfYear.Item2, "Mountain Standard Time");
DateTime londonTime = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(timeOfYear.Item2, "GMT Standard Time");
DateTime dubaiTime = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(timeOfYear.Item2, "Arab Standard Time");
DateTime sydneyTime = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(timeOfYear.Item2, "AUS Eastern Standard Time");
Console.WriteLine($"CALGARY TIME: {calgaryTime}");
Console.WriteLine($"LONDON TIME: {londonTime}");
Console.WriteLine($"DUBAI TIME: {dubaiTime}");
Console.WriteLine($"SYDNEY TIME: {sydneyTime}");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment