ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/AnywhereTS-MSSQL/trunk/TSAdminTool/TimeZone.cs
Revision: 47
Committed: Thu Jul 12 14:29:34 2012 UTC (10 years, 10 months ago) by william
File size: 1800 byte(s)
Log Message:
+ fix compilation errors

File Contents

# Content
1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4 using System.Windows.Forms;
5 using log4net;
6 namespace AnywhereTS
7 {
8 static class ATSTimeZone
9 {
10 // The input cultures for rdesktop. Each culture is languagecode_countrycode or just languagecode
11 public static string[] timeZoneCode = new string[] { "UTC-12", "UTC-11", "UTC-10", "UTC-9", "UTC-8", "UTC-7", "UTC-6", "UTC-5", "UTC-4", "UTC-3", "UTC-2", "UTC-1", "UTC+0", "UTC+1", "UTC+2", "UTC+3", "UTC+4", "UTC+5", "UTC+6", "UTC+7", "UTC+8", "UTC+9", "UTC+10", "UTC+11", "UTC+12", "UTC+13", "UTC+14" };
12
13 // Returns the default timezone from the windows settings on the current computer.
14 public static string DefaultTimeZone()
15 {
16 int timeOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(System.DateTime.Now).Hours;
17 if (timeOffset >= -12 && timeOffset <= 14)
18 return timeZoneCode[timeOffset + 12];
19 else
20 return timeZoneCode[12]; // Time zone not valid, return UTC+0
21 }
22
23 // Returns the index for a time zone code.
24 public static int TimeZoneCodeToIndex(string searchTimeZoneCode)
25 {
26 for (int i = 0; i <= timeZoneCode.GetUpperBound(0); i++)
27 {
28 if (timeZoneCode[i] == searchTimeZoneCode)
29 {
30 return i;
31 }
32 }
33 // Not found
34 MessageBox.Show("Error illegal time zone (24553)");
35 using (log4net.NDC.Push(string.Format("keyboard code={0}", searchTimeZoneCode)))
36 {
37 Logging.ATSAdminLog.Error("Error illegal time zone (24553)");
38 }
39 return 12; // UTC+0
40 }
41 }
42 }