aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Date problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Date problem" Watch "Date problem" New topic
Author

Date problem

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42908
    
  69
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
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
Marshal

Joined: Mar 22, 2005
Posts: 42908
    
  69
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
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
Marshal

Joined: Mar 22, 2005
Posts: 42908
    
  69
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Date problem