KDE Bug Tracking System
Home
Report New Wish or Bug
Query Existing Reports
First
Last
Prev
Next
No search results available
Search page
Bug
98027
:
getday javascript function returns a NaN
P
roduct
:
konqueror
Co
m
ponent
:
kjs
Status
:
RESOLVED
Resolution
:
FIXED
Target
:
---
Version
:
unspecified
Pr
i
ority
:
NOR
Severity
:
normal
V
otes
:
0
Description
:
Opened:
2005-01-27 23:16
Last Changed:
2005-04-17 19:08:41
Version: (using KDE KDE 3.3.2) Installed from: Gentoo Packages Compiler: gcc version 3.3.5 OS: Linux this javaScript will check if a date entered is a Saturday or a Sunday. It will work correctly in gecko or IE based browsers but returns a NaN (I am assuming Not a Number) in Konqueror. It gets its values from a form. The user will enter in a month day and year (all in separate drop-down boxes) This is the code on the page: //Check if the date entered is a saturday or sunday var month_index = form.month.selectedIndex; var month = form.month.options[month_index].text; var day_index = form.day.selectedIndex; var day = form.day.options[day_index].text; var year_index = form.year.selectedIndex; var year = form.year.options[year_index].text; var d=new Date(month + day + "," + year); var day_of_week = d.getDay(); if ((day_of_week == 6) || (day_of_week == 0)) { alert("You have chosen a date on the weekend"); form.day.focus(); return (false); }
Comment
#1
George Staikos 2005-01-27 23:28:20
I guess the form is the key here. getDay() works fine for me. What does "d" show for you?
Comment
#2
trpn myrealbox com 2005-01-28 02:41:08
d shows 'Invalid Date' in konqueror d shows 'Sat Jan 29 2005 00:00:00 GMT -0500 (Eastern Standard Time)' in Firefox Same form, same server, same exact input on the form
Comment
#3
George Staikos 2005-01-28 03:26:40
> ------- d shows 'Invalid Date' in konqueror
>
> d shows 'Sat Jan 29 2005 00:00:00 GMT -0500 (Eastern Standard Time)' in > Firefox
>
> Same form, same server, same exact input on the form
So the problem is in the construction of the Date object. What is the exact text passed into "new Date()"?
Comment
#4
trpn myrealbox com 2005-01-28 04:27:15
each variable ends up as follows month: January Day: 29 Year: 2005 so... d should end up looking like: new Date(January + 29 + "," + 2005); this is where the problem is. I suppose it happens when the variables are attached together using the + sign.
Comment
#5
George Staikos 2005-01-28 04:42:55
On Thursday 27 January 2005 22:27,
trpn@myrealbox.com
wrote:
> ------- each variable ends up as follows
>
> month: January > Day: 29 > Year: 2005
>
> so...
>
> d should end up looking like: new Date(January + 29 + "," + 2005);
>
> this is where the problem is. I suppose it happens when the variables are > attached together using the + sign.
So the real testcase is: d = new Date("January29,2005"); if (d.getDay() == NaN) { // failed } Mozilla is capable of parsing this date while KJS is not?
Comment
#6
trpn myrealbox com 2005-01-28 04:56:07
On January 27, 2005 10:42 pm, George Staikos wrote:
> So the real testcase is:
>
> d = new Date("January29,2005"); > if (d.getDay() == NaN) { > // failed > }
>
> Mozilla is capable of parsing this date while KJS is not?
That would be correct. Actually after looking at it I do not think that is proper code d = new Date("January29,2005"); should be: d = new Date("January 29, 2005"); changing the actual code to: d=new Date(month + " " + day + ", " + year) works...... I guess this is not a bug but rather kjs is not picking up user error while mozilla and IE are.
Comment
#7
Harri Porten 2005-04-17 19:08:40
CVS commit by porten: parse date strings like "Apr17,2005" BUGS:98027 M +2 -0 ChangeLog 1.62 M +5 -0 date_object.cpp 1.97 --- kdelibs/kjs/ChangeLog #1.61:1.62 @@ -1,4 +1,6 @@ 2005-04-17 Harri Porten <
porten@kde.org
> + * date_object.cpp: parse date strings like "Apr17,2005" + * function.cpp: don't produce a null string result on unescape("") (spotted in the JSC ChangeLog) --- kdelibs/kjs/date_object.cpp #1.96:1.97 @@ -789,4 +789,9 @@ double KJS::KRFCDate_parseDate(const USt dateString++; } + // missing delimiter between month and day (like "January29")? + if (month == -1 && dateString && wordStart != dateString) { + month = findMonth(wordStart); + // TODO: emit warning about dubious format found + } while(*dateString && isspace(*dateString))
P
latform
:
Gentoo Packages
O
S
:
Linux
K
eywords
:
People
Reporter
:
Assigned To
:
Konqueror Developers
Related actions
View Bug Activity
Format For Printing
XML
Clone This Bug
Note
You need to
log in
before you can comment on or make changes to this bug.
Attachments
Add an attachment
(proposed patch, testcase, etc.)
Depends on
:
B
locks
:
Show dependency tree
-
Show dependency graph
First
Last
Prev
Next
No search results available
Search page
Actions
Reports
Requests
Reports
Bugs reported today
Bugs reported in the last 3 days
Bug reports with patches
Weekly Bug statistics
The most hated bugs
The most severe bugs
The most frequently reported bugs
The most wanted features
Junior Jobs
Report ownership counts and charts
My Account
New Account
Log In