Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Wrox Announcements and Feedback > Forum and Wrox.com Feedback
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Forum and Wrox.com Feedback Post your suggestions for improving the Forums or Wrox.com or questions for the staff here. "Where can I find the code for my book?"
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Forum and Wrox.com Feedback section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Closed Thread
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 22nd, 2004, 03:25 PM
Imar's Avatar
Wrox Author
Points: 72,038, Level: 100
Points: 72,038, Level: 100 Points: 72,038, Level: 100 Points: 72,038, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,080
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default Another Daylight Saving Issue?

Hi all,

Back in March I noticed an issue with the DST options on the forum.
It turned out that Europe and the US use different times to swith between winter and summer time. (http://p2p.wrox.com/topic.asp?TOPIC_ID=11622)

It was also said than in October we'd switch back.

Ever since the switch, the time is an hour off again. It says it's 9:19 pm, while over here it's 8:19 pm.

Is it a bug this time, or hasn't the time changed on the P2P servers?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: I Let Love In by Nick Cave & the Bad Seeds (Track 6 from the album: Let Love In) What's This?
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
  #2 (permalink)  
Old November 22nd, 2004, 04:17 PM
Friend of Wrox
 
Join Date: May 2003
Location: Indianapolis, IN, USA.
Posts: 207
Thanks: 0
Thanked 1 Time in 1 Post
Default

It should be fixed now.

It was a strange ASP date comparison issue. Apparently 10/31/2004 02:00:00 doesn't compare the same as 10/31/2004 02:00:00 [u]AM</u>.

The code that builds the end date for DST starts with the last day in October at 2:00am and while that day is not a Sunday, subtracts one day. The goal is to find the last Sunday in October. This year it was 10/31 so the loop didn't have to iterate.

The code looked like this:
Code:
endDate = "10/31/" & currentYear & " 02:00:00"
while DatePart("w",endDate) <> 1
    endDate=DateAdd("d",-1,endDate)
wend
The result of this code for this year is 10/31/2004 02:00:00 since no loops were required (10/31 was a Sunday).

Strangely enough, the following test returns true (when it should fail):
Code:
startDate = "04/04/2004 02:00:00 AM"
endDate = "10/31/2004 02:00:00"

if (now() >= startDate) and (now() <= endDate) then
    'Adjust for daylight savings time
end if
Notice the missing "AM" on the endDate. Adding that back in makes the test work correctly. The reason the code failed this year is because no loops were required. The DateAdd function would add the "AM" back on to the date.

Very strange.

Bruce Luckcuck
Director, Applications & Support Services
Wiley Publishing, Inc.
  #3 (permalink)  
Old November 22nd, 2004, 05:30 PM
Imar's Avatar
Wrox Author
Points: 72,038, Level: 100
Points: 72,038, Level: 100 Points: 72,038, Level: 100 Points: 72,038, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,080
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi Bruce,

Thanks for fixing this, and thanks for the detailed explanation.

It is indeed weird. From what I can see, the test should indeed fail. Then again, dates and times are always causing odd problems, so I am not really that surprised. Maybe you should convert the end- and startdate to a datevalue first.....

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
  #4 (permalink)  
Old November 22nd, 2004, 06:20 PM
Friend of Wrox
 
Join Date: May 2003
Location: Indianapolis, IN, USA.
Posts: 207
Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
quote:Originally posted by Imar
 Maybe you should convert the end- and startdate to a datevalue first.....


That's basically what I did to fix the problem. I just changed the logic to start one day outside DST to force one iteration of the DateAdd.

I've been asked why I need to keep calculating the date and can't I just store it once (from an efficiency perspective). The problem is that all dates and times presented in the site must be adjusted. Thus I always need to find the begin/end dates for the year of the date in question. I suppose I could cache the dates by year since there shouldn't be that many different years. It comes down to balancing the I/O of a database read vs. a small loop of (at most) 7 iterations. Well, that's for when I'm bored and have absolutely nothing else to do. :D

Bruce Luckcuck
Director, Applications & Support Services
Wiley Publishing, Inc.
Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Seagate/Crystal Report 7.0 Extended DayLight savin jdaulagar Beginning VB 6 0 February 26th, 2007 02:44 PM
EXCEL question saving a file saving the the first macupryk VS.NET 2002/2003 0 January 6th, 2005 05:33 PM
United States Daylight Savings Time mega Forum and Wrox.com Feedback 4 August 24th, 2004 08:03 AM
How To avoid the SAving of toolbars while saving Hari_Word Excel VBA 6 July 26th, 2004 12:13 AM
Daylight Saving Time bug in the Snitz forum? Imar Forum and Wrox.com Feedback 4 March 29th, 2004 02:04 PM



All times are GMT -4. The time now is 05:35 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.