Utcnow IsDayLightSaving() problem

  • Thread starter Thread starter Varangian
  • Start date Start date
V

Varangian

Hello there,

I'm having a problem with Utcnow property. I'm checking the Utcnow for
IsDayLightSaving() if true or false. I'm setting the timezone to GMT
time London etc and during summer when daylight saving is applied hence
GMT Daylight time.

However the System.DateTime.Utcnow.IsDayLightSaving() always returns
false even when it is on GMT Daylight time. Whats this.. what I'm
missing?

Thanks for any insights
 
Varangian said:
I'm having a problem with Utcnow property. I'm checking the Utcnow for
IsDayLightSaving() if true or false. I'm setting the timezone to GMT
time London etc and during summer when daylight saving is applied hence
GMT Daylight time.

However the System.DateTime.Utcnow.IsDayLightSaving() always returns
false even when it is on GMT Daylight time. Whats this.. what I'm
missing?

A UTC date-time surely *never* has daylight savings time applied to it,
by definition. That's what I'd have expected.

Jon
 
If I am reading the documentation correctly, the IsDaylightSavings() ALWAYS
returns false if the 'Kind' property of the DateTime is Utc. Thus I would
think that DateTime.UtcNow.IsDaylightSavings() always returns false,
whereas DateTime.Now.IsDaylightSavings() might return true if it truly is
Daylight Savings. The 'Kind' property is new to .NET 2.0, so if you are
using 1.1 you won't see it, but it still might be there. Try using
DateTime.Now instead.

Also, Are you actually setting the time on your computer, or just setting
the timezone? I would think that your computer time must be set to a
date/time during which it is ACTUALLY Daylight Savings. We are currently
on Standard Time (DST runs from early April to late October.)

-mdb
 
The strange thing is when I apply to GMT time zone on my computer and
set the time a minute before daylight savings apply and wait until the
minute passes say for example for this year it is on 01:00.... I set it
to 00:59 and wait until it applies. I see that the time would be 02:00.
So there seems to be daylight saving in the GMT Time zone. And in fact
in my code I check by System.DateTime.Now.IsDayLightSaving() and
returns true.

strange but true. Thanks Jon Skeet
 
Thats what I'm doing, I'm actually setting on the windows datetime on
the taskbar to 26/03/2006 01:59. I thought that Utcnow is the same as
GMT Time set on the your computer which it seems is not.
 
Thats what I'm doing, I'm actually setting on the windows datetime on
the taskbar to 26/03/2006 01:59. I thought that Utcnow is the same as
GMT Time set on the your computer which it seems is not.

Thanks Michael bray
 
Varangian said:
The strange thing is when I apply to GMT time zone on my computer and
set the time a minute before daylight savings apply and wait until the
minute passes say for example for this year it is on 01:00.... I set it
to 00:59 and wait until it applies. I see that the time would be 02:00.
So there seems to be daylight saving in the GMT Time zone. And in fact
in my code I check by System.DateTime.Now.IsDayLightSaving() and
returns true.

Well, I'm in the UK and always pick GMT as my time zone - but
definitely apply daylight savings. In the summer we're in BST (British
Summer Time). I suspect there are two sort of parallel considerations
for GMT going on, effectively. However, UTC is a "constant" - it's GMT
without daylight savings, effectively. (Actually, I've a suspicion
there are some subtle differences in terms of leap seconds etc, but
nothing to worry about.)

Jon
 
Back
Top