Figuring out daylight saving time?

  • Thread starter Thread starter Lothar Behrens
  • Start date Start date
L

Lothar Behrens

Hi,

I played with the following code in my project and figured out that
when the application is not restarted and I change the date from
26.01.2011 to 20.07.2011 the code does not change the label to
indicate summer time.

Only after I restart the application, the change is recognized.

Why does this not work while the application keeps running?

private void button1_Click(object sender, EventArgs e)
{
if (DateTime.Now.IsDaylightSavingTime())
label1.Text = "It is daylight saving time";
else
label1.Text = "It is not daylight saving time";
}

Thanks,

Lothar
 
Hi,

I played with the following code in my project and figured out that
when the application is not restarted and I change the date from
26.01.2011 to 20.07.2011 the code does not change the label to
indicate summer time.

Only after I restart the application, the change is recognized.

Why does this not work while the application keeps running?

        private void button1_Click(object sender, EventArgs e)
        {
            if (DateTime.Now.IsDaylightSavingTime())
                label1.Text = "It is daylight saving time";
            else
                label1.Text = "It is not daylight saving time";
        }

Thanks,

Lothar

It seens only sometimes not be correct. I don't know why this happens.
 
It seens only sometimes not be correct. I don't know why this happens.

Do you restart the app after changing date?

Do you restart Windows after changing date?

One obvious explanation would be that some information is cached
somewhere either in .NET or Windows.

Arne
 
Back
Top