EDN Admin
Well-known member
Hi All!<br/>
<br/>
I have some issue when getting strange result from method TimeZone.CurrentTimeZone.GetUtcOffset()<br/>
<br/>
OS: Windows 8, Development environment: Visual Studio 2008 Version 9.0.30729.4462 QFE<br/>
<br/>
Here is the step-by-step procedure to recreate the issue.<br/>
<br/>
1. Set "(UTC+12:00) Auckland, Wellington" time zone on your local machine. Means the daylight period ends 07-April-2013 at 03:00 AM<br/>
<br/>
2. Set date and time 07-April-2013 01:52 AM on your development machine<br/>
<br/>
3. Run following simple test
<pre class="prettyprint DateTime dt = DateTime.Now;
Console.WriteLine(String.Format("Start time: {0}", dt));
for (int i = 0; i < 15; i++)
{
dt = dt.AddMinutes(1);
Console.WriteLine(String.Format("Date: {2}, Adding {0} minutes. Offset is: {1}", i,
TimeZone.CurrentTimeZone.GetUtcOffset(dt).TotalMinutes, dt));
}
[/code]
The output is:<br/>
Start time: 4/7/2013 1:51:32 AM<br/>
Date: 4/7/2013 1:52:32 AM, Adding 0 minutes. Offset is: 780 - 13 hours<br/>
Date: 4/7/2013 1:53:32 AM, Adding 1 minutes. Offset is: 780<br/>
Date: 4/7/2013 1:54:32 AM, Adding 2 minutes. Offset is: 780<br/>
Date: 4/7/2013 1:55:32 AM, Adding 3 minutes. Offset is: 780<br/>
Date: 4/7/2013 1:56:32 AM, Adding 4 minutes. Offset is: 780<br/>
Date: 4/7/2013 1:57:32 AM, Adding 5 minutes. Offset is: 780<br/>
Date: 4/7/2013 1:58:32 AM, Adding 6 minutes. Offset is: 780<br/>
Date: 4/7/2013 1:59:32 AM, Adding 7 minutes. Offset is: 780<br/>
Date: 4/7/2013 2:00:32 AM, Adding 8 minutes. Offset is: 720 - 12 hours<br/>
Date: 4/7/2013 2:01:32 AM, Adding 9 minutes. Offset is: 720<br/>
Date: 4/7/2013 2:02:32 AM, Adding 10 minutes. Offset is: 720<br/>
Date: 4/7/2013 2:03:32 AM, Adding 11 minutes. Offset is: 720<br/>
Date: 4/7/2013 2:04:32 AM, Adding 12 minutes. Offset is: 720<br/>
Date: 4/7/2013 2:05:32 AM, Adding 13 minutes. Offset is: 720<br/>
Date: 4/7/2013 2:06:32 AM, Adding 14 minutes. Offset is: 720<br/>
<br/>
Before 02:00 AM the result looks correct: 780 minutes which is 12 hours + 1 daylight period. <br/>
After 02:00 AM the offset is 720 minutes which is 12 hours. This looks like an issue. Im expecting to get 13 hours till 03:00 AM when daylight period end.<br/>
Missing I something?
Thank you very much,
Evgeny <hr class="sig EvgenyV
View the full article
<br/>
I have some issue when getting strange result from method TimeZone.CurrentTimeZone.GetUtcOffset()<br/>
<br/>
OS: Windows 8, Development environment: Visual Studio 2008 Version 9.0.30729.4462 QFE<br/>
<br/>
Here is the step-by-step procedure to recreate the issue.<br/>
<br/>
1. Set "(UTC+12:00) Auckland, Wellington" time zone on your local machine. Means the daylight period ends 07-April-2013 at 03:00 AM<br/>
<br/>
2. Set date and time 07-April-2013 01:52 AM on your development machine<br/>
<br/>
3. Run following simple test
<pre class="prettyprint DateTime dt = DateTime.Now;
Console.WriteLine(String.Format("Start time: {0}", dt));
for (int i = 0; i < 15; i++)
{
dt = dt.AddMinutes(1);
Console.WriteLine(String.Format("Date: {2}, Adding {0} minutes. Offset is: {1}", i,
TimeZone.CurrentTimeZone.GetUtcOffset(dt).TotalMinutes, dt));
}
[/code]
The output is:<br/>
Start time: 4/7/2013 1:51:32 AM<br/>
Date: 4/7/2013 1:52:32 AM, Adding 0 minutes. Offset is: 780 - 13 hours<br/>
Date: 4/7/2013 1:53:32 AM, Adding 1 minutes. Offset is: 780<br/>
Date: 4/7/2013 1:54:32 AM, Adding 2 minutes. Offset is: 780<br/>
Date: 4/7/2013 1:55:32 AM, Adding 3 minutes. Offset is: 780<br/>
Date: 4/7/2013 1:56:32 AM, Adding 4 minutes. Offset is: 780<br/>
Date: 4/7/2013 1:57:32 AM, Adding 5 minutes. Offset is: 780<br/>
Date: 4/7/2013 1:58:32 AM, Adding 6 minutes. Offset is: 780<br/>
Date: 4/7/2013 1:59:32 AM, Adding 7 minutes. Offset is: 780<br/>
Date: 4/7/2013 2:00:32 AM, Adding 8 minutes. Offset is: 720 - 12 hours<br/>
Date: 4/7/2013 2:01:32 AM, Adding 9 minutes. Offset is: 720<br/>
Date: 4/7/2013 2:02:32 AM, Adding 10 minutes. Offset is: 720<br/>
Date: 4/7/2013 2:03:32 AM, Adding 11 minutes. Offset is: 720<br/>
Date: 4/7/2013 2:04:32 AM, Adding 12 minutes. Offset is: 720<br/>
Date: 4/7/2013 2:05:32 AM, Adding 13 minutes. Offset is: 720<br/>
Date: 4/7/2013 2:06:32 AM, Adding 14 minutes. Offset is: 720<br/>
<br/>
Before 02:00 AM the result looks correct: 780 minutes which is 12 hours + 1 daylight period. <br/>
After 02:00 AM the offset is 720 minutes which is 12 hours. This looks like an issue. Im expecting to get 13 hours till 03:00 AM when daylight period end.<br/>
Missing I something?
Thank you very much,
Evgeny <hr class="sig EvgenyV
View the full article