惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Help Net Security
博客园 - Franky
GbyAI
GbyAI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
爱范儿
爱范儿
IT之家
IT之家
酷 壳 – CoolShell
酷 壳 – CoolShell
aimingoo的专栏
aimingoo的专栏
博客园_首页
MongoDB | Blog
MongoDB | Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recent Announcements
Recent Announcements
Scott Helme
Scott Helme
有赞技术团队
有赞技术团队
M
MIT News - Artificial intelligence
C
CERT Recently Published Vulnerability Notes
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Jina AI
Jina AI
F
Fortinet All Blogs
N
Netflix TechBlog - Medium
L
LangChain Blog
L
LINUX DO - 最新话题
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
H
Hacker News: Front Page
MyScale Blog
MyScale Blog
P
Palo Alto Networks Blog
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
AI
AI
T
Troy Hunt's Blog
Microsoft Azure Blog
Microsoft Azure Blog
阮一峰的网络日志
阮一峰的网络日志
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
罗磊的独立博客
S
Secure Thoughts
大猫的无限游戏
大猫的无限游戏
博客园 - 叶小钗
人人都是产品经理
人人都是产品经理
Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
Apple Machine Learning Research
Apple Machine Learning Research
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
S
Security @ Cisco Blogs
Cloudbric
Cloudbric
E
Exploit-DB.com RSS Feed
Attack and Defense Labs
Attack and Defense Labs

博客园 - DODONG

在现有PDF文件上添加水印 c#获取硬件信息 一个读写csv文件的C#类 . C#操作Excel文件(读取Excel,写入Excel) . 利用ReportViewer读取Reporting Service数据 [转]用反射来处理多字段提交 查询数据表中重复的记录 CVS文件导入SQL ComponentArt.Web.UI中AJAX TreeView 抽象工厂(Abstract Factory)模式 简单工厂(Simple Factory)模式 工厂方法(Factory Method)模式 用.NET创建Windows服务 关于SharePoint中查询写法和注意的地方 关于&运算符和^ 初识WAP开发时.. C#操作XML XMLHttp客户端操作数据 asp.net网页智能导航SmartNavigation的替代实现方式
解决全球化时区问题
DODONG · 2011-04-26 · via 博客园 - DODONG

  1 using System;
  2 using System.Collections.Generic;
  3 using System.Linq;
  4 using System.Web;
  5 using System.Web.UI;
  6 using System.Web.UI.WebControls;
  7 using System.Runtime.InteropServices;
  8 using Microsoft.Win32;
  9 using System.Collections;
 10 
 11 namespace WebApplication3
 12 {
 13     public partial class _Default : System.Web.UI.Page
 14     {
 15 
 16         const string c_WinNTKey = @"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones";
 17         const string c_Win9xKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Time Zones";
 18         const string c_KeyDisplay = "Display ";
 19         const string c_KeyDayLightName = "Dlt ";
 20         const string c_KeyStandardName = "Std ";
 21         const string c_KeyTZI = "TZI ";
 22         static ArrayList s_TimeZones = new ArrayList();
 23         ///   <summary> 
 24         ///   The   main   entry   point   for   the   application. 
 25         ///   </summary> 
 26         [DllImport("Kernel32.dll ")]
 27         static extern bool TzSpecificLocalTimeToSystemTime(ref   Class1.TIME_ZONE_INFORMATION lpTimeZoneInformation, ref   Class1.SYSTEMTIME lpLocalTime, ref    Class1.SYSTEMTIME lpUniversalTime);
 28 
 29         [DllImport("Kernel32.dll ")]
 30         static extern bool SystemTimeToTzSpecificLocalTime(ref   Class1.TIME_ZONE_INFORMATION lpTimeZone, ref   Class1.SYSTEMTIME lpUniversalTime, ref    Class1.SYSTEMTIME lpLocalTime);
 31 
 32 
 33         protected void Page_Load(object sender, EventArgs e)
 34         {
 35 
 36             switch (Environment.OSVersion.Platform)
 37             {
 38                 case PlatformID.Win32NT:
 39                     RetrieveWinNTTimeZones();
 40                     break;
 41                 case PlatformID.Win32Windows:
 42                     break;
 43                 default:
 44                     break;
 45             }
 46             DateTime dtUTC = DateTime.Now.ToUniversalTime();
 47             Class1.SYSTEMTIME stUTC = dtUTC;
 48             Class1.SYSTEMTIME st = new Class1.SYSTEMTIME();
 49             Class1.TIME_ZONE_INFORMATION tzi;
 50 
 51             Label2.Text = string.Format("{0,-50}{1} ""UTC ", dtUTC.ToString());
 52 
 53             foreach (Class1.TimeZoneInfo dzi in s_TimeZones)
 54             {
 55                 tzi = dzi.TZI;
 56                 SystemTimeToTzSpecificLocalTime(ref   tzi, ref   stUTC, ref   st);
 57  
 58                 Label1.Text += string.Format("{0,   -50}{1} ", dzi.Name, ((DateTime)st).ToString())+"<BR>";
 59             }
 60 
 61 
 62         }
 63 
 64 
 65         static void RetrieveWinNTTimeZones()
 66         {
 67             using (RegistryKey baseKey = Registry.LocalMachine.OpenSubKey(c_WinNTKey))
 68             {
 69                 if (baseKey == null)
 70                 {
 71                     throw new InvalidOperationException(string.Format("Registry   key  {0} open   failed ", c_WinNTKey));
 72                 }
 73                 string[] tzNames = baseKey.GetSubKeyNames();
 74                 string tzDisplay;
 75                 string tzDaylightName;
 76                 string tzStandardName;
 77                 byte[] tzTZI;
 78 
 79                 foreach (string tzName in tzNames)
 80                 {
 81                     using (RegistryKey tzKey = baseKey.OpenSubKey(tzName))
 82                     {
 83                         tzDisplay = tzKey.GetValue("Display"string.Empty) as string;
 84                         tzDaylightName = tzKey.GetValue("Dlt"string.Empty) as string;
 85                         tzStandardName = tzKey.GetValue("Std"string.Empty) as string;
 86                         tzTZI = tzKey.GetValue("TZI"string.Empty) as byte[];
 87                         s_TimeZones.Add(
 88                                 new Class1.TimeZoneInfo
 89                                 (
 90                                 tzName, tzDisplay,
 91                                 tzDaylightName,
 92                                 tzStandardName,
 93                                 new Class1.REG_TIME_ZONE_INFORMATION
 94                                     (tzTZI)
 95                                     )
 96                                 );
 97                     }
 98                 }
 99             }
100         }
101         //-----------------
102     }
103 }