471,319 Members | 2,675 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,319 software developers and data experts.

Utcnow IsDayLightSaving() problem

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

Jan 16 '06 #1
6 7073
Varangian wrote:
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

Jan 16 '06 #2
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

Jan 16 '06 #3
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

"Varangian" <of****@gmail.com> wrote in news:1137422513.885462.241620
@g47g2000cwa.googlegroups.com:
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


Jan 16 '06 #4
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.

Jan 16 '06 #5
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

Jan 16 '06 #6
Varangian wrote:
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

Jan 16 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Steve Erickson | last post: by
11 posts views Thread by Kostatus | last post: by
9 posts views Thread by Sudesh Sawant | last post: by
117 posts views Thread by Peter Olcott | last post: by
reply views Thread by James Griffiths | last post: by
18 posts views Thread by Ian Stanley | last post: by
reply views Thread by Elizabeth Harmon | last post: by
1 post views Thread by T-u-N-i-X | last post: by
36 posts views Thread by Nick | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.