-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCheckTimeZone.cs
More file actions
43 lines (35 loc) · 1.69 KB
/
CheckTimeZone.cs
File metadata and controls
43 lines (35 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
* Check TimeZone between different countries
*/
using System;
using System.Collections.Generic;
Console.WriteLine("\nChecking the Timezones from different countries: \n");
var saoPauloBrazil = TimeZoneInfo.FindSystemTimeZoneById("E. South America Standard Time");
var austinTexas = TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time");
var india = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time");
var romenia = TimeZoneInfo.FindSystemTimeZoneById("GTB Standard Time");
DateTime saoPauloTime = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, saoPauloBrazil);
DateTime austinTime = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, austinTexas);
DateTime indiaTime = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, india);
DateTime romeniaTime = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, romenia);
// Dictionary with the values
Dictionary<string, string> allTimes = new Dictionary<string, string>();
allTimes.Add("UTC", DateTime.UtcNow.ToString("G"));
allTimes.Add("BRAZIL", saoPauloTime.ToString("G"));
allTimes.Add("TEXAS", austinTime.ToString("G"));
allTimes.Add("INDIA", indiaTime.ToString("G"));
allTimes.Add("ROMENIA", romeniaTime.ToString("G"));
foreach (KeyValuePair<string, string> time in allTimes)
{
// The Box with the values
int padding = 2;
string content = $"│ -> {time.Key} {time.Value}";
int width = content.Length + padding;
string top = "╭" + new string('─', width - 2) + "╮";
string middle = content + new string(' ', width - content.Length - 1) + "│";
string bottom = "╰" + new string('─', width - 2) + "╯";
Console.WriteLine(top);
Console.WriteLine(middle);
Console.WriteLine(bottom);
}
Console.WriteLine("\n");