473,513 Members | 2,307 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

NaN

Anyone know why in Safari the Server date shows as NaN but in FF and IE it
shows up fine.

The display :

http://new4.saguarogold.net/index.html

The clock code

http://new4.saguarogold.net/scripts/clock.js

Any ideas?

Jun 3 '07 #1
12 2964
in article C2*******************@noone.com, Phat G5 (G3) at no****@noone.com
wrote on 6/2/07 6:37 PM:
Anyone know why in Safari the Server date shows as NaN but in FF and IE it
shows up fine.

The display :

http://new4.saguarogold.net/index.html

The clock code

http://new4.saguarogold.net/scripts/clock.js

Any ideas?
BTW, if anyone has suggestions to simplify or clean it up please let me
know. :D

-S

Jun 3 '07 #2
in article C2*******************@noone.com, Phat G5 (G3) at no****@noone.com
wrote on 6/2/07 7:08 PM:
in article C2876969.6F673%no****@noone.com, Phat G5 (G3) at no****@noone.com
wrote on 6/2/07 6:37 PM:
>Anyone know why in Safari the Server date shows as NaN but in FF and IE it
shows up fine.

The display :

http://new4.saguarogold.net/index.html

The clock code

http://new4.saguarogold.net/scripts/clock.js

Any ideas?

BTW, if anyone has suggestions to simplify or clean it up please let me
know. :D

-S
No takers? :D

Jun 3 '07 #3
In comp.lang.javascript message <C2*******************@noone.com>, Sat,
2 Jun 2007 18:37:29, "Phat G5 (G3)" <no****@noone.composted:
>http://new4.saguarogold.net/scripts/clock.js
Whoever write that code should have learned Javascript and read the
newsgroup FAQ (with care) first.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6
news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Jun 3 '07 #4
On Jun 4, 5:04 am, "Phat G5 (G3)" <nob...@noone.comwrote:
in article C28770B2.6F680%nob...@noone.com, Phat G5 (G3) at nob...@noone.com
wrote on 6/2/07 7:08 PM:
in article C2876969.6F673%nob...@noone.com, Phat G5 (G3) at nob...@noone.com
wrote on 6/2/07 6:37 PM:
Anyone know why in Safari the Server date shows as NaN but in FF and IE it
shows up fine.
The display :
>http://new4.saguarogold.net/index.html
The clock code
>http://new4.saguarogold.net/scripts/clock.js
Any ideas?
BTW, if anyone has suggestions to simplify or clean it up please let me
know. :D
-S

No takers? :D
Apparently not. It doesn't "work" in Firefox either, I get a server
time of 23:59:50 on 31 December, 1970 when the page loads. I also get
a message saying "You have no new emails as of 01:11:39 AM
06/04/2007".

The loading animation seems pointless - after it displays for several
seconds, I still have to wait for the rest of the page to display.
That kind of page loading style was ditched in the 90's, there's a
reason why browsers show pages as the HTML arrives - it's what users
want. Good page authors have worked out how to code pages so that
they are displayed quickly with correct layout from the start.

The animated stuff is annoying as hell. Most people don't care what
the "server time" is (of what possible use is it?) and don't need a
local clock either. If they want one, they'll have it in their menu
bar (or some other handy position) already.

The date display seems odd - 06/04/2007 indicates 6 April 2007 to me.

The script seems unnecessarily long, e.g. the "DaysInMonth" function
can be re-written as:

function daysInMonth(month, year) {
return (new Date(year, month, 0)).getDate();
}

where month is jan=1, feb=2, etc. It may not suit all browsers that
you wish to support.

But it isn't needed anyway, follow JRS's link to read about dates and
clocks.

--
Rob
Jun 4 '07 #5
in article k$**************@invalid.uk.co.demon.merlyn.invali d, Dr J R
Stockton at jr*@merlyn.demon.co.uk wrote on 6/3/07 8:58 AM:
In comp.lang.javascript message <C2*******************@noone.com>, Sat,
2 Jun 2007 18:37:29, "Phat G5 (G3)" <no****@noone.composted:
>http://new4.saguarogold.net/scripts/clock.js

Whoever write that code should have learned Javascript and read the
newsgroup FAQ (with care) first.
That script is a consolidation of 2 different scripts out on the net. I went
thru it and deleted a bunch of crap that was old. It started working and so
I have to stop and get onto more crucial parts and come back to it later on.
What specifically from the faq are you referring to? What really makes it
all that bad?

-S

Jun 4 '07 #6
Phat G5 (G3) said the following on 6/4/2007 12:39 PM:
in article k$**************@invalid.uk.co.demon.merlyn.invali d, Dr J R
Stockton at jr*@merlyn.demon.co.uk wrote on 6/3/07 8:58 AM:
>In comp.lang.javascript message <C2*******************@noone.com>, Sat,
2 Jun 2007 18:37:29, "Phat G5 (G3)" <no****@noone.composted:
>>http://new4.saguarogold.net/scripts/clock.js
Whoever write that code should have learned Javascript and read the
newsgroup FAQ (with care) first.

That script is a consolidation of 2 different scripts out on the net.
Most of what you find "on the net" isn't worth copying though.
I went thru it and deleted a bunch of crap that was old.
Then why is there a branch for a browser that is so outdated that it is
a pain to even find the last version of it? (Netscape 4). Typically, if
you see code that has if(document.layers) then you can rest assured it
is 10 years old or so.
It started working and so I have to stop and get onto
more crucial parts and come back to it later on.
As long as its a goal to get it updated, more efficient and quicker,
then there is nothing wrong with it.
What specifically from the faq are you referring to? What really makes it
all that bad?
The first thing I do when looking at code from the web is do a search
for the word "eval" and typically if you find it then it isn't very well
written. And it is true in this case. In the displayTime function you
have this code:

else if (document.layers)
{
var x = eval('document.layers.'+ obj);

var xWithoutEval = document.layers[obj];

//code here
}
else if (document.all)
{
var x = eval(obj)

var xWithoutEval = document.all[obj];

//code here

The advantage is that you aren't calling eval which starts a separate
instance of the compiler/engine and makes it more efficient. The other
problem with eavl(obj) is that it depends on a flaw in IE where it makes
the ID/NAME attribute a global variable and if a browser exists that
takes the document.all branch that doesn't make it a Global then it will
error out when that error can be easily avoided.

The function daysInMonth has this code:
if (WhichMonth == "Feb" && (WhichYear/4) != Math.floor(WhichYear/4))
DaysInMonth = 28;
if (WhichMonth == "Feb" && (WhichYear/4) == Math.floor(WhichYear/4))
DaysInMonth = 29;

The problem with that code will manifest itself every 400 years as leap
year is not a simple matter of dividing by 4, every 400 years there is
no leap day (test it for 2000).

John also won't like your date format or the fact that you used AM/PM
instead of a 24 hour clock.

There is probably more but I got tired of looking.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jun 4 '07 #7
in article dM********************@giganews.com, Randy Webb at
Hi************@aol.com wrote on 6/4/07 2:19 PM:
Phat G5 (G3) said the following on 6/4/2007 12:39 PM:
>in article k$**************@invalid.uk.co.demon.merlyn.invali d, Dr J R
Stockton at jr*@merlyn.demon.co.uk wrote on 6/3/07 8:58 AM:
>>In comp.lang.javascript message <C2*******************@noone.com>, Sat,
2 Jun 2007 18:37:29, "Phat G5 (G3)" <no****@noone.composted:

http://new4.saguarogold.net/scripts/clock.js
Whoever write that code should have learned Javascript and read the
newsgroup FAQ (with care) first.

That script is a consolidation of 2 different scripts out on the net.

Most of what you find "on the net" isn't worth copying though.
>I went thru it and deleted a bunch of crap that was old.

Then why is there a branch for a browser that is so outdated that it is
a pain to even find the last version of it? (Netscape 4). Typically, if
you see code that has if(document.layers) then you can rest assured it
is 10 years old or so.
>It started working and so I have to stop and get onto
more crucial parts and come back to it later on.

As long as its a goal to get it updated, more efficient and quicker,
then there is nothing wrong with it.
>What specifically from the faq are you referring to? What really makes it
all that bad?

The first thing I do when looking at code from the web is do a search
for the word "eval" and typically if you find it then it isn't very well
written. And it is true in this case. In the displayTime function you
have this code:

else if (document.layers)
{
var x = eval('document.layers.'+ obj);

var xWithoutEval = document.layers[obj];

//code here
}
else if (document.all)
{
var x = eval(obj)

var xWithoutEval = document.all[obj];

//code here

The advantage is that you aren't calling eval which starts a separate
instance of the compiler/engine and makes it more efficient. The other
problem with eavl(obj) is that it depends on a flaw in IE where it makes
the ID/NAME attribute a global variable and if a browser exists that
takes the document.all branch that doesn't make it a Global then it will
error out when that error can be easily avoided.

The function daysInMonth has this code:
if (WhichMonth == "Feb" && (WhichYear/4) != Math.floor(WhichYear/4))
DaysInMonth = 28;
if (WhichMonth == "Feb" && (WhichYear/4) == Math.floor(WhichYear/4))
DaysInMonth = 29;

The problem with that code will manifest itself every 400 years as leap
year is not a simple matter of dividing by 4, every 400 years there is
no leap day (test it for 2000).

John also won't like your date format or the fact that you used AM/PM
instead of a 24 hour clock.

There is probably more but I got tired of looking.
Randy,

Thank you for taking the time to respond with more than to just read the
faq. I had completely forgotten the issues with the document.layers[xxx].
That was a good flashback. I'll be taking all that out anyway. The browsers
that will be using this will support the document.getElementById() so that
should be fine. I'll make those other changes and work on it some more and
then post back for a better idea.

On another note... What exactly is the best way to calculate whether or not
it is a leap year via js?

Thanks,
-S

Jun 4 '07 #8
Phat G5 (G3) said the following on 6/4/2007 5:54 PM:
in article dM********************@giganews.com, Randy Webb at
Hi************@aol.com wrote on 6/4/07 2:19 PM:
<snip>
>There is probably more but I got tired of looking.
Randy,

Thank you for taking the time to respond with more than to just read the
faq. I had completely forgotten the issues with the document.layers[xxx].
That was a good flashback. I'll be taking all that out anyway. The browsers
that will be using this will support the document.getElementById() so that
should be fine. I'll make those other changes and work on it some more and
then post back for a better idea.
Then you can remove the document.all as well then. Just check for gEBI
and return false if it isn't supported.
On another note... What exactly is the best way to calculate whether or not
it is a leap year via js?
Simple, short and concise?

<URL:
http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/f7f972aec32c483e/d8f5b4ef5d988327?lnk=gst&q=leap+year&rnum=2#d8f5b4 ef5d988327>

Is a thread that has several ways to determine it. Which you use is
entirely up to you.

<quote RobG>
A year is a leap year if it is evenly divisible by four and not 100, or
if evenly divisible by 400. It can be written as:

if ( (!(year%4) && !!(year%100)) || !(year%400) )
{
// Year is a leap year
} else {
// Year is not a leap year
}
</quote>

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jun 4 '07 #9
In comp.lang.javascript message <dM********************@giganews.com>,
Mon, 4 Jun 2007 17:19:42, Randy Webb <Hi************@aol.composted:
>
The problem with that code will manifest itself every 400 years as leap
year is not a simple matter of dividing by 4, every 400 years there is
no leap day (test it for 2000).

Your memory is failing, or is failing to update. It was 1900 when there
was last a missing February 29th, which is the cause of some uncertainty
concerning the natal year of Frederic of Penzance.

Y = 2000
M = 2
z = new Date(Date.UTC(Y, M, 0)).getUTCDate()

IIRC, the final Feb 29 of a millennium is alternately Tuesday & Friday.

While on the subject, more or less, of Opera :

Query - <URL:http://www.merlyn.demon.co.uk/estrdate.htm#CDhas a
button, "Pop Code Up". That's been OK in IE & FF, but in my Opera 9.21
the first 5 or so characters of the written string, which should start
"<pre>\n", are usually corrupted (they appear as random foreign, and the
<preis of course destroyed).

The actual code is in function PopThis(btn) in include1.js line
Wndw.document.write("<pre>\n", SafeHTML(Obj.Str), "\n<\/pre>")
and if I add a few spaces at the start of the first string the
corruption appears but does no real harm.

Do others see that in Opera?

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6.
Web <URL:http://www.merlyn.demon.co.uk/- w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/- see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Jun 5 '07 #10
Dr J R Stockton wrote:
In comp.lang.javascript message <dM********************@giganews.com>,
Mon, 4 Jun 2007 17:19:42, Randy Webb <Hi************@aol.composted:
>The problem with that code will manifest itself every 400 years as leap
year is not a simple matter of dividing by 4, every 400 years there is
no leap day (test it for 2000).


Your memory is failing, or is failing to update. It was 1900 when there
was last a missing February 29th, which is the cause of some uncertainty
concerning the natal year of Frederic of Penzance.

Y = 2000
M = 2
z = new Date(Date.UTC(Y, M, 0)).getUTCDate()

IIRC, the final Feb 29 of a millennium is alternately Tuesday & Friday.

While on the subject, more or less, of Opera :

Query - <URL:http://www.merlyn.demon.co.uk/estrdate.htm#CDhas a
button, "Pop Code Up". That's been OK in IE & FF, but in my Opera 9.21
the first 5 or so characters of the written string, which should start
"<pre>\n", are usually corrupted (they appear as random foreign, and the
<preis of course destroyed).

The actual code is in function PopThis(btn) in include1.js line
Wndw.document.write("<pre>\n", SafeHTML(Obj.Str), "\n<\/pre>")
and if I add a few spaces at the start of the first string the
corruption appears but does no real harm.

Do others see that in Opera?
Yep. Upon several presses it went from garbled to Asian characters.
Not sure if this will stay as is (I am going to send as UTF-8), but here
was one instance: "櫰ǬŸ’>."

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
Jun 5 '07 #11
In comp.lang.javascript message <C2*******************@noone.com>, Mon,
4 Jun 2007 14:54:37, "Phat G5 (G3)" <no****@noone.composted:
>On another note... What exactly is the best way to calculate whether or not
it is a leap year via js?
That is very rarely needed - it's not needed for date validation, for
example.

But it can be determined by
!new Date(y, 1, 366).getMonth()
or !!(!(y%4) ^ !(y%100) ^ !(y%400))
or !( y & 3 || y & 15 && !(y % 25) )
or by many other ways which you could have found via the FAQ.

It's a good idea to read the newsgroup c.l.j and its FAQ. See below.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6
news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Jun 5 '07 #12
In comp.lang.javascript message <84KdnT5GVLSYP_jbnZ2dnUVZ_uKknZ2d@comcas
t.com>, Tue, 5 Jun 2007 13:50:14, -Lost <ma****************@techie.com>
posted:
> The actual code is in function PopThis(btn) in include1.js
line
Wndw.document.write("<pre>\n", SafeHTML(Obj.Str), "\n<\/pre>")
and if I add a few spaces at the start of the first string the
corruption appears but does no real harm.
Do others see that in Opera?

Yep. Upon several presses it went from garbled to Asian characters.
Not sure if this will stay as is (I am going to send as UTF-8), but
here was one instance: "??Ÿ’>."
I think "non-Ascii" is more accurate than Asian; I think I've seen Maths
there. Random, no doubt.

Thanks. I've reported it to Opera.

Frederic : <URL:http://www.merlyn.demon.co.uk/leapyear.htm#TPoP>

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6.
Web <URL:http://www.merlyn.demon.co.uk/- w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/- see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Jun 6 '07 #13

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

Similar topics

3
11180
by: William C. White | last post by:
Does anyone know of a way to use PHP /w Authorize.net AIM without using cURL? Our website is hosted on a shared drive and the webhost company doesn't installed additional software (such as cURL)...
2
5775
by: Albert Ahtenberg | last post by:
Hello, I don't know if it is only me but I was sure that header("Location:url") redirects the browser instantly to URL, or at least stops the execution of the code. But appearantely it continues...
3
22959
by: James | last post by:
Hi, I have a form with 2 fields. 'A' 'B' The user completes one of the fields and the form is submitted. On the results page I want to run a query, but this will change subject to which...
0
8436
by: Ollivier Robert | last post by:
Hello, I'm trying to link PHP with Oracle 9.2.0/OCI8 with gcc 3.2.3 on a Solaris9 system. The link succeeds but everytime I try to run php, I get a SEGV from inside the libcnltsh.so library. ...
1
8540
by: Richard Galli | last post by:
I want viewers to compare state laws on a single subject. Imagine a three-column table with a drop-down box on the top. A viewer selects a state from the list, and that state's text fills the...
4
18217
by: Albert Ahtenberg | last post by:
Hello, I have two questions. 1. When the user presses the back button and returns to a form he filled the form is reseted. How do I leave there the values he inserted? 2. When the...
1
6777
by: inderjit S Gabrie | last post by:
Hi all Here is the scenerio ...is it possibly to do this... i am getting valid course dates output on to a web which i have designed ....all is okay so far , look at the following web url ...
2
31348
by: Jack | last post by:
Hi All, What is the PHP equivilent of Oracle bind variables in a SQL statement, e.g. select x from y where z=:parameter Which in asp/jsp would be followed by some statements to bind a value...
3
23534
by: Sandwick | last post by:
I am trying to change the size of a drawing so they are all 3x3. the script below is what i was trying to use to cut it in half ... I get errors. I can display the normal picture but not the...
0
7265
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
7388
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
7545
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7111
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7539
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...
0
4751
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
3240
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
3228
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1605
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.