473,473 Members | 2,098 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

IsDaylightSavingTime Not Working Correctly

MJR
I live in Arizona. We of course do not change for DST. All of the
data that is inserted into our database is in Arizona time. My client
wants me to display the Time Zone the record was inserted in relation
to Eastern Time. So all of the dates should be displayed as either PST
or MST depanding on the time of the year.

I am trying to use IsDaylightSavingTime to find out if the date in the
database was inserted during DST. The code for my if condition is:

if(TimeZone.CurrentTimeZone.IsDaylightSavingTime(c allDate))
{
e.Item.Cells[2].Text = e.Item.Cells[2].Text + " PST";
}
else
{
e.Item.Cells[2].Text = e.Item.Cells[2].Text + " MST";
}

No matter if 'callDate' is 1/5/2005 or 7/5/2005 IsDaylightSavingTime
always returns false. I even tried changing my local box to Pacific
Timezone but it made no difference.
Is there something I am missing?

Thanks in advance,
Mike

Nov 16 '05 #1
2 6517
"MJR" <mi******@gmail.com> wrote in
news:11**********************@f14g2000cwb.googlegr oups.com:
I live in Arizona. We of course do not change for DST. All of
the data that is inserted into our database is in Arizona time.
My client wants me to display the Time Zone the record was
inserted in relation to Eastern Time. So all of the dates should
be displayed as either PST or MST depanding on the time of the
year.

I am trying to use IsDaylightSavingTime to find out if the date
in the database was inserted during DST. The code for my if
condition is:

if(TimeZone.CurrentTimeZone.IsDaylightSavingTime(c allDate))
{
e.Item.Cells[2].Text = e.Item.Cells[2].Text + " PST";
}
else
{
e.Item.Cells[2].Text = e.Item.Cells[2].Text + " MST";
}
Mike,

You may want to read this:

http://msdn.microsoft.com/library/en...tetimecode.asp

or

http://tinyurl.com/6xkdz

You can see what the DST settings are for your current timezone by
calling TimeZone.CurrentTimeZone.GetDaylightChanges(callDa te.Year).
This returns a DaylightTime instance, and its Delta, Start and End
properties will tell you if .Net is detecting your DST settings
correctly.
No matter if 'callDate' is 1/5/2005 or 7/5/2005
IsDaylightSavingTime always returns false. I even tried changing
my local box to Pacific Timezone but it made no difference.
Is there something I am missing?


Did you restart your application after changing timezones? Using
Reflector to examine the CurrentTimeZone property, it only gets
the current time zone once when it's first called. It doesn't
detect a change in time zones.

--
Hope this helps.

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/
Nov 16 '05 #2
Aside from the code, I think there is an erroneous assumption above -- all times would not be either PST or MST.

If I am sitting in California (which I happen to be doing), a few minutes ago it was 5:00 PM PDT. Four weeks ago (on 3/25), the time would've been 5:00 PM PST. When DST is active, then you are in Daylight Time. When DST is not active, you are in Standard Time. In Arizona, you are always on Standard time.

You can avoid that by leaving out the middle letter -- just call it "PT" or "Pacific Time" and "MT" or "Mountain Time" -- not sure if the abbreviations are formally used though.

From http://www.developmentnow.com/g/36_2...-Correctly.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com
Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Don Leckie | last post by:
Hi, I'm upgrading our software from JDK 1.3.1_03 to JDK 1.4.2_07 and I'm having trouble with ComponentOrientation.RIGHT_TO_LEFT working correctly in a JScrollPane. One of my windows has a...
2
by: Kamyk | last post by:
Hello all! Could you tell me where is the error on the below code, because the script is sometimes working correctly and sometimes is not working correctly. I want my new window with picture...
17
by: Jonathan Burd | last post by:
Greetings everyone, Reading about the int64_t types added by C'99, I decided to implement a 64-bit version of atoi for my own library. However, for the test number provided, it isn't doing what...
0
by: mikejrae | last post by:
I live in Arizona. We of course do not change for DST. All of the data that is inserted into our database is in Arizona time. My client wants me to display the Time Zone the record was inserted...
10
by: Scott Richards | last post by:
Hi I am getting a exception while using a datareader here is the code Me.SqlConnection1.Open() Me.SqlReservationCheck.Parameters("@Ref").Value = Ref Dim Reader As SqlClient.SqlDataReader = _...
8
by: jojobar | last post by:
Okay, I am trying to do is to test the webresource in 2.0 1. I created a new project with assembly name (and default assembly name) "Office". 2. I added the following to the AssemblyInfo.cs...
9
by: MSDNAndi | last post by:
Hi, I have a set of simple webservices calls that worked fine using .NET Framework 1.0. I am calling a Java/Apache based webservices, the calling side is not able to supply a proper WSDL. ...
3
by: doomsday123 | last post by:
Will private bool IsDST(DateTime d) { return System.TimeZone.IsDaylightSavingTime(d, System.TimeZone.CurrentTimeZone.GetDaylightChanges(d.Year)); } in .NET 1.1 return the same thing as this...
1
by: Mark B | last post by:
This is my first try at using AJAX. I want the calendars to be enabled if the user checks CheckBox1. It works OK for a normal all page refresh but once I introduced the AJAX code it stopped...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.