Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Date problem

 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have a web app that is reportedly causing problems on a British Windows system, while on a German Windows it works fine. The problem is in date calculations using JavaScript. I'm already aware that -contrary to the documentation- getDay and getUTCDay return differing values for Sunday, so we're not using those any more, yet still calculations are off by a day.
Does this ring a bell with anyone? Could there be timezone issues? It's happening now, so it's not a daylight savings time issue. I can't give more details, because I don't have any, and can't corroborate what's happening, but I thought maybe someone has run into something like this, and could clue me in as to what else to watch out for when using dates in JS.

Many thanks in advance for any hints!
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have the code that is doing the calculation?

Are you using different date format?
Is the clock set to the correct date if you are reading local time?

Eric
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've put up a minimal example on my web page. What's supposed to happen is that you enter a start date and an end date, and that the respective weekday fields are set, and some validation happens (you can't set end to before start, and the start date can't be before today).
What's happening on the British Windows is that if you select a date, it automatically sets it to the next day, as if the current day were in the past. I wonder if it's a timezone thing, but I can't reproduce it, no matter how I change the country settings or timezone on my German OS.
If anyone has a clue what I should watch out for, that'd be great.
[ December 01, 2005: Message edited by: Ulf Dittmer ]
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I get the error too and I can not figure out your code since I do not know why you are going through all of that to get days and such.

Look through this thread here: http://webdeveloper.com/forum/showthread.php?t=61883&highlight=prototype+Eric

look at the date functions there for prototypes to do calculations. They may show you some good ways to count days and such.

Eric
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for looking, Eric. Yeah, the code is complicated (and there's even more for related purposes that I removed to simplify).

You actually gave me an important clue -unwittingly, I suspect - since I had tried with a US OS, and not seen the problem. So it's definitely got something to do with timezones, not country or region settings, and by choosing a far-off timezone I can now reproduce the bug. A happy conclusion should not be far off.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic