.NETGURU
Daylight Saving Time Problems
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngcs' list.


Julian Voelcker
I have an ASP.net (C#) application that provides access to certain
functionality at a set time of day.

The application checks reads the time from a field in the database and
then if that time has passed it provides users with access to the
functionality.

This all works fine, except that it is one hour out which I suspect is
because it is/isn't taking into account daylight saving.

I'm using DateTime dNow = DateTime.Now to determine the current time.

Has anyone come across a similar problem?

I either need to find some way of reading the time as displayed in the
server's taskbar or to be able to automatically adjust the time for
daylight saving.

Any suggestions?

Cheers,

Julian Voelcker
The Virtual World (UK) Limited
Cirencester, United Kingdom

Reply to this message...
 
    
Brian W. Spolarich

I'm wondering if your system's clock is properly configured with the =
correct timezone and DST setting. It could be showing the correct time =
but incorrectly configured.

Check out the System.TimeZone class. You can use something like this =
to see what .NET is getting.

            TimeZone myTz =3D System.TimeZone.CurrentTimeZone;
            if ( myTz.IsDaylightSavingTime(System.DateTime.Now) =3D=3D true )
            {
                Response.Write("<B>IsDST</B>");
            }
            else
            {
                Response.Write("<B>IsNotDST</B>");
            }

-bws

| -----Original Message-----
| From: Julian Voelcker [mailto:Click here to reveal e-mail address]
| Sent: Wednesday, July 10, 2002 5:16 AM
| To: aspngcs
| Subject: [aspngcs] Daylight Saving Time Problems
|=20
|=20
| I have an ASP.net (C#) application that provides access to certain=20
| functionality at a set time of day.
|=20
| The application checks reads the time from a field in the=20
| database and=20
| then if that time has passed it provides users with access to the=20
| functionality.
|=20
| This all works fine, except that it is one hour out which I=20
| suspect is=20
| because it is/isn't taking into account daylight saving.
|=20
| I'm using DateTime dNow =3D DateTime.Now to determine the current =
time.
|=20
| Has anyone come across a similar problem?
|=20
| I either need to find some way of reading the time as=20
| displayed in the=20
| server's taskbar or to be able to automatically adjust the time for=20
| daylight saving.

Reply to this message...
 
    
Ryan Trudelle-Schwarz
Why not make it easy on yourself and work in UTC?

-> -----Original Message-----
-> From: Julian Voelcker [mailto:Click here to reveal e-mail address]
->
-> I have an ASP.net (C#) application that provides access to certain
-> functionality at a set time of day.
->
-> The application checks reads the time from a field in the database
and
-> then if that time has passed it provides users with access to the
-> functionality.
->
-> This all works fine, except that it is one hour out which I suspect
is
-> because it is/isn't taking into account daylight saving.
->
-> I'm using DateTime dNow = DateTime.Now to determine the current time.
->
-> Has anyone come across a similar problem?
->
-> I either need to find some way of reading the time as displayed in
the
-> server's taskbar or to be able to automatically adjust the time for
-> daylight saving.
->
-> Any suggestions?
->
-> Cheers,
->
-> Julian Voelcker

---
[This E-mail scanned for viruses by Declude Virus]

Reply to this message...
 
    
Julian Voelcker
Brian,

Thanks, I have run your code and it checks out OK.

The server is configured at GMT time (we are UK based) and the box is
ticked for automatically adjusting for daylight saving.

I do recall seeing this on another server some time ago, but cannot
remember how the problem was resolved.

I think that it may have something to do with the way the system clock
is set in the BIOS, but I can't remember whether it should be set using
the summertime or not.

Any more ideas?

Cheers,

Julian Voelcker
The Virtual World (UK) Limited
Cirencester, United Kingdom
[Original message clipped]

Reply to this message...
 
    
Julian Voelcker
I'm working with GMT anyway, which is the same sort of thing isn't it.

Here are a few more details which may explain the problem.

We have an online chat facility with chats being scheduled at certain
times of the day. The client sets up a chat via a content management
system and enters the time the chat starts and ends which is then saved to
the back end database.

At the appropriate time a link to the chat room appears in a menu on the
site - currently if the chat is set to start at 9am the link isn't
appearing until 10am.

I could insist that the client does the working out to establish whether
is BST or not and then get them to enter an adjusted time, however as far
as they are concerned it is a bug in the system and it is not down to them
to do such calculations.

Have any of you come across something similar?

Cheers,

Julian Voelcker
The Virtual World (UK) Limited
Cirencester, United Kingdom
On Wed, 10 Jul 2002 12:34:53 -0400, Ryan Trudelle-Schwarz wrote:
[Original message clipped]

Reply to this message...
 
    
Brian W. Spolarich

| Thanks, I have run your code and it checks out OK.

Do you mean that .NET is correctly reporting that=20

(System.TimeZone.IsDaylightSavingTime(System.DateTime.Now) =3D=3D =
true) ?

I'm curious what the following fragment produces on your system:

            TimeZone myTz =3D System.TimeZone.CurrentTimeZone;
            DateTime myTime =3D System.DateTime.Now;

            Response.Write("Local Time: " + myTime.ToString() + "<P>");
            Response.Write("Universal Time: " + =
myTime.ToUniversalTime().ToString() + "<P>");
            Response.Write("TZ: " + myTz.StandardName + " (GMT" + =
myTz.GetUtcOffset(myTime) + ")<P>");

            if ( myTz.IsDaylightSavingTime(myTime) =3D=3D true )
                Response.Write("IsDST<P>");
            else
                Response.Write("IsNotDST<P>");

| The server is configured at GMT time (we are UK based) and the box is=20
| ticked for automatically adjusting for daylight saving.
|=20
| I do recall seeing this on another server some time ago, but cannot=20
| remember how the problem was resolved.
|=20
| I think that it may have something to do with the way the system clock =

| is set in the BIOS, but I can't remember whether it should be=20
| set using the summertime or not.
|=20
| Any more ideas?

I found this article:

=
http://support.microsoft.com/search/preview.aspx?scid=3Dkb;en-us;Q234735

I would suggest if possible you do the following:

1. Shut down the system and restart and check the time in the BIOS. =
Set the time to the correct local time.

2. Start Windows 2000 and as Administrator set the =
time/timezone/dst/date settings. You might try setting them to =
something else and then setting them back.

3. Run the test again.

-bws

Reply to this message...
 
    
Ryan Trudelle-Schwarz
Are you using the System.DateTime.UTCNow? That should not contain any
time zone specific info (like daylight savings time).

-> -----Original Message-----
-> From: Julian Voelcker [mailto:Click here to reveal e-mail address]
-> Sent: Thursday, July 11, 2002 4:36 AM
-> To: aspngcs
-> Subject: [aspngcs] Re: Daylight Saving Time Problems
->
-> I'm working with GMT anyway, which is the same sort of thing isn't
it.
->
-> On Wed, 10 Jul 2002 12:34:53 -0400, Ryan Trudelle-Schwarz wrote:
-> > Why not make it easy on yourself and work in UTC?
-> >
-> > -> -----Original Message-----
-> > -> From: Julian Voelcker [mailto:Click here to reveal e-mail address]
-> > ->
-> > -> I have an ASP.net (C#) application that provides access to
certain
-> > -> functionality at a set time of day.
-> > ->
-> > -> The application checks reads the time from a field in the
database
-> > and
-> > -> then if that time has passed it provides users with access to
the
-> > -> functionality.
-> > ->
-> > -> This all works fine, except that it is one hour out which I
suspect
-> > is
-> > -> because it is/isn't taking into account daylight saving.
-> > ->
-> > -> I'm using DateTime dNow = DateTime.Now to determine the current
-> time.
-> > ->
-> > -> Has anyone come across a similar problem?
-> > ->
-> > -> I either need to find some way of reading the time as displayed
in
-> > the
-> > -> server's taskbar or to be able to automatically adjust the time
for
-> > -> daylight saving.
-> > ->
-> > -> Any suggestions?
-> > ->
-> > -> Cheers,
-> > ->
-> > -> Julian Voelcker
-> >

---
[This E-mail scanned for viruses by Declude Virus]

Reply to this message...
 
    
Julian Voelcker
Brian, thanks for the help so far.

I ran your code and it produced the following:-

Local Time: 12/07/2002 09:27:06
Universal Time: 12/07/2002 08:27:06
TZ: GMT Standard Time (GMT01:00:00)
IsDST

Interestingly the problem now seems to have resolved itself - I suspect
that going in and out of the timezone settings has finally saved the
settings correctly.

Thanks again to everyone for their help.

Next time I'll start off by kicking the server before hassling you lot.

Cheers,

Julian Voelcker
The Virtual World (UK) Limited
Cirencester, United Kingdom

Reply to this message...
 
    
Julian Voelcker
On Thu, 11 Jul 2002 11:34:15 -0400, Ryan Trudelle-Schwarz wrote:
[Original message clipped]

No, I don't really want to use that because the client will have to
change the times they enter into UTC, which I don't think is
satisfactory.

Cheers,

Julian Voelcker
The Virtual World (UK) Limited
Cirencester, United Kingdom

Reply to this message...
 
 
System.DateTime
System.TimeZone




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification