东澳大利亚夏令时和DateTime.IsDaylightSavings()可能存在的错误 [英] Possible bug with Eastern Australian Daylight Savings and DateTime.IsDaylightSavings()

查看:117
本文介绍了东澳大利亚夏令时和DateTime.IsDaylightSavings()可能存在的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!
$


在澳大利亚调查了一个问题后,我想知道我是否偶然发现了Windows /中的一个错误。净或如果我错过了什么..



参考新南威尔士州网站,2018/2019年的夏令时结束于2019年4月7日03: 00。此时,他们停止夏令时(AEDT - UCT + 11),时钟返回1小时(AEST - UCT + 1000)。

Hi All!

After looking into an issue with a custoemr in Australia, i am wondering if i have stumbled across a bug in Windows/.Net or if i'm just missing something..

Referencing the New South Wales website, their Daylight savings period for 2018/2019 ends on 7th April 2019 at 03:00. At this point, they stop Daylight Savings (AEDT - UCT+11) and the clocks go back 1 hour (AEST - UCT+1000).

DateTime.IsDaylightSavings()方法似乎返回错误地基于日期。它似乎说2019年3月31日的DST开始,而它始于2018年10月,应该在2019年4月7日结束。

DateTime.IsDaylightSavings() method seems to return incorrectly based on date. It seems to say that the DST STARTS on 31st March 2019 whereas it started in October 2018 and should END on 7th April 2019.

你可以通过运行以下2个命令看到这个:

You can see this by running the following 2 commands:

TimeZoneInfo.ConvertTimeFromUtc(new DateTime(2019,3,30,0,0,0, DateTimeKind.Utc), TimeZoneInfo.FindSystemTimeZoneById("AUS Eastern Standard Time")).IsDaylightSavingTime();


TimeZoneInfo.ConvertTimeFromUtc(new DateTime(2019,3,31,0,0,0, DateTimeKind.Utc), TimeZoneInfo.FindSystemTimeZoneById("AUS Eastern Standard Time")).IsDaylightSavingTime();

如果我遗失,请告诉我某事或如果这是一个错误。



Please let me know if i am missing something or if this is a bug.

推荐答案

您的示例可能会检查计算机的当前时区。 ( DateTime 不存储时区)。

Your examples probably check the current timezone of your computer. (DateTime does not store the timezone).

检查另一种方法:


var tz = TimeZoneInfo.FindSystemTimeZoneById( "AUS Eastern Standard Time" );

bool b3 = tz.IsDaylightSavingTime( new DateTime( 2019, 3, 30, 0, 0, 0, DateTimeKind.Utc ) ); // true
bool b4 = tz.IsDaylightSavingTime( new DateTime( 2019, 3, 31, 0, 0, 0, DateTimeKind.Utc ) ); // true
bool b5 = tz.IsDaylightSavingTime( new DateTime( 2019, 4, 7, 1, 0, 0, DateTimeKind.Unspecified ) ); // true
bool b6 = tz.IsDaylightSavingTime( new DateTime( 2019, 4, 7, 5, 0, 0, DateTimeKind.Unspecified ) ); // false
bool b7 = tz.IsAmbiguousTime( new DateTime( 2019, 4, 7, 2, 30, 0, DateTimeKind.Unspecified ) ); // true






这篇关于东澳大利亚夏令时和DateTime.IsDaylightSavings()可能存在的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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