ConvertTimeFromUTC,处理澳大利亚DST [英] ConvertTimeFromUTC, Handling Australia DST

查看:70
本文介绍了ConvertTimeFromUTC,处理澳大利亚DST的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码,并且在澳大利亚堪培拉有一个客户。它们通常是UTC + 10,但是它们现在在DST中,所以它是UTC + 11。奇怪的是,当我运行这段代码时,它并没有考虑DST,我认为ConvertTimeFromUTC会处理DST。

I have the following code, and I have a a customer in Canberra, Australia. They are typically UTC+10, however they are in DST right now so it is UTC+11. What is odd is when I run this code it is not accounting for DST, which I thought ConvertTimeFromUTC handles.

我正在传递 E。澳大利亚标准时间作为 timeZone参数。有什么想法吗?

I am passing E. Australia Standard Time as the "timeZone" parameter. Any thoughts?

var myTimeZone = TimeZoneInfo.FindSystemTimeZoneById(timeZone);
var currentDateTime = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, myTimeZone);
return currentDateTime;


推荐答案

使用 AUS Eastern Standard时间 用于使用DST的东南澳大利亚(新南威尔士州和维多利亚州),包括堪培拉,墨尔本,悉尼等。

Use "AUS Eastern Standard Time" for South-East Australia (New South Wales and Victoria) that uses DST, including Canberra, Melbourne, Sydney, etc.

使用 E。Australia标准时间 用于没有具有夏令时的东北澳大利亚(昆士兰州),包括布里斯班,林德曼等。

Use "E. Australia Standard Time" for North-East Australia (Queensland) that does not have DST, including Brisbane, Lindeman, etc.

否则,您的代码是正确的。

Otherwise, your code is correct.

请注意,尽管时区ID中有标准一词, .NET和Windows将在适用的情况下正确考虑DST。没有ID中包含日光一词。

Note that despite having the word "Standard" in the time zone IDs, .NET and Windows will correctly account for DST where applicable. There are no IDs that have the word "Daylight" in them.

有关时区的完整列表,请使用 TimeZoneInfo.GetSystemTimeZones()并检查每个属性的 .Id .DisplayName 属性。或者,在命令行上调用 tzutil.exe / l

For a complete list of time zones, use TimeZoneInfo.GetSystemTimeZones() and examine the .Id and .DisplayName properties of each. Alternatively, call tzutil.exe /l on the command line which will do the same.

这篇关于ConvertTimeFromUTC,处理澳大利亚DST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆