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: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77:
| private void Worldtimer(object sender, EventArgs e) { string displayShanghai = "(GMT+07:00) China/Shanghai Time"; string displayBerlin = "(GMT+01:00) Deutschland/Berlin Time"; string displayLondon = "(GMT+00:00) England/London Time"; string displaySeoul = "(GMT+06:00) Korea/Seoul Time"; string displaySydney = "(GMT+11:00) Australien/Sydney Time"; string displayNewYork = "(GMT-05:00) America/New York Time";
string standard_shanghai = "Shanghai Time"; string standard_berlin = "Berlin Time"; string standard_london = "London Time"; string standard_seoul = "Seoul Time"; string standard_sydney = "Sydney Time"; string standard_newyork = "New York Time";
TimeSpan shanghai_offset = new TimeSpan(07, 00, 00); TimeSpan berlin_offset = new TimeSpan(01, 00, 00); TimeSpan london_offset = new TimeSpan(00, 00, 00); TimeSpan seoul_offset = new TimeSpan(06, 00, 00); TimeSpan sydney_offset = new TimeSpan(11, 00, 00); TimeSpan newyork_offset = new TimeSpan(-05, 00, 00);
TimeZoneInfo str_Shanghai = TimeZoneInfo.CreateCustomTimeZone(standard_shanghai, shanghai_offset, displayShanghai, standard_shanghai); TimeZoneInfo str_Berlin = TimeZoneInfo.CreateCustomTimeZone(standard_berlin, berlin_offset, displayBerlin, standard_berlin); TimeZoneInfo str_London = TimeZoneInfo.CreateCustomTimeZone(standard_london, london_offset, displayLondon, standard_london); TimeZoneInfo str_Seoul = TimeZoneInfo.CreateCustomTimeZone(standard_seoul, seoul_offset, displaySeoul, standard_seoul); TimeZoneInfo str_Sydney = TimeZoneInfo.CreateCustomTimeZone(standard_sydney, sydney_offset, displaySydney, standard_sydney); TimeZoneInfo str_Newyork = TimeZoneInfo.CreateCustomTimeZone(standard_newyork, newyork_offset, displayNewYork, standard_newyork);
string data_shanghai = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.Local, str_Shanghai).ToString(); string data_berlin = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.Local, str_Berlin).ToString(); string data_london = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.Local, str_London).ToString(); string data_seoul = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.Local, str_Seoul).ToString(); string data_sydney = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.Local, str_Sydney).ToString(); string data_newyork = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.Local, str_Newyork).ToString();
string[] substr1 = Regex.Split(data_shanghai, " "); string[] substr2 = Regex.Split(data_berlin, " "); string[] substr3 = Regex.Split(data_london, " "); string[] substr4 = Regex.Split(data_seoul, " "); string[] substr5 = Regex.Split(data_sydney, " "); string[] substr6 = Regex.Split(data_newyork, " ");
switch (toolStripComboBox_world.SelectedIndex) { case 0: Label_time.Text = substr2.GetValue(1).ToString(); Label_date.Text = substr2.GetValue(0).ToString(); break; case 1: Label_time.Text = substr3.GetValue(1).ToString(); Label_date.Text = substr3.GetValue(0).ToString(); break; case 2: Label_time.Text = substr1.GetValue(1).ToString(); Label_date.Text = substr1.GetValue(0).ToString(); break; case 3: Label_time.Text = substr4.GetValue(1).ToString(); Label_date.Text = substr4.GetValue(0).ToString(); break; case 4: Label_time.Text = substr5.GetValue(1).ToString(); Label_date.Text = substr5.GetValue(0).ToString(); break; case 5: Label_time.Text = substr6.GetValue(1).ToString(); Label_date.Text = substr6.GetValue(0).ToString(); break; default: Label_time.Text = DateTime.Now.ToShortTimeString(); Label_date.Text = DateTime.Now.ToShortDateString(); break; } } |