473,763 Members | 6,401 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Y2K problem with script?

Below is an old count-up script that displays ok in MSIE with a bit of
experimenting, but NS shows negative values that make no sense. Anyone
know how to make it work ok in both?

=== Cut ===
<script language=JavaSc ript>
/*
Date Count-up 1.0
(C) Copyright 1996 Ben Harold
All rights Reserved
Feel free to use this script in your page under the folling
conditions :
1. Do not modify this script in any way (besides
following the
configuration directions) without my consent
2. Mail me at bh*****@indyuni x.iupui.edu if you use it
3. I am not held responsible for any thing that this
script may
do to your computer
*/

// Configuration Directions
// Don't change this
// This makes a date variable that is used to get the current date

today = new Date()

// Don't change these

// These get the current year, month, and date

var thisyear = today.getYear()
var thismonth = today.getMonth( )
var thisdate = today.getDate()

// Change these
// These set the year, month, and date to count from
// NOTICE : var thatmonth should be a number between 0 and 11, not 1
and 12

var thatyear = 1995
var thatmonth = 10
var thatdate = 15

// Change this
// This is what the browser will display just before the years, months,
and dates
// NOTICE : make sure that there is a space after the last word of var
prestring

var prestring = " "

// Don't change these
// These set variables used by other parts of the script

var fromyears = (thisyear - thatyear)
var datenumber = (thisdate + thatdate)

// Don' change this
// This figures out how many days there are in the current month

if (thismonth == 0)
monthdates = (31)
else if (thismonth == 1)
monthdates = (28)
else if (thismonth == 2)
monthdates = (31)
else if (thismonth == 3)
monthdates = (30)
else if (thismonth == 4)
monthdates = (31)
else if (thismonth == 5)
monthdates = (30)
else if (thismonth == 6)
monthdates = (31)
else if (thismonth == 7)
monthdates = (31)
else if (thismonth == 8)
monthdates = (30)
else if (thismonth == 9)
monthdates = (31)
else if (thismonth == 10)
monthdates = (30)
else if (thismonth == 11)
monthdates = (31)

// Don't change this
// This figures out how many years it has been since thatyear

if (fromyears == 0)
yearssince = (prestring)

else if (fromyears == 1)
yearssince = (prestring + " year")

else yearssince = (prestring + fromyears + " years")

// Don't change this
// This figures out how many dates it has been since thatdate

if (thisdate > thatdate)
predatessince = (thisdate - thatdate)
else predatessince = (thisdate + monthdates - thatdate)
if (predatessince == 0)
datessince = ("no days.")
else if (predatessince == 1)
datessince = ("1 day.")
else datessince = (predatessince + " days.")

// Don't change this
// This figures out how many months it has been since thatmonth

if (thisyear > thatyear) {
if (thismonth >= thatmonth)
premonthssince = (thismonth -
thatmonth)
else premonthssince = (12 + thismonth -
thatmonth)
}

else premonthssince = (thismonth - thatmonth)

if (monthdates < datenumber)
premonthssincet wo = (premonthssince + 1)
else premonthssincet wo = (premonthssince )
if (premonthssince two == 0)
monthssince = (" ")
else if (premonthssince two == 1)
monthssince = ("1 month")
else monthssince = (premonthssince two +
"months")

// Don't change these
// These figure out what type of punctuation to use in the final
message

if (yearssince == prestring)
commaone = (" ")
else {
if (monthssince == " ")
(commaone = " and ")
else commaone = (", ")
}

if (commaone == " and ")
commatwo = (" ")
else if (commaone == ", ")
commatwo = (" and ")
else if (yearssince == prestring) {
if (monthssince == " ")
(commatwo = " ")
else commatwo = (" and ")
}

// Don't change this
// This assembles the final message

var finalstring = ""
finalstring += (yearssince)
finalstring += (commaone)
finalstring += (monthssince)
finalstring += (commatwo)
finalstring += (datessince)

// Don't change this
// This prints the final message to the browser screen

document.write( finalstring)
</script>
=== Cut ===
Kari Suomela

KARICO Business Services
Toronto, ON Canada
http://www.karico.ca

.... Never straighten a good waistline.
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Sep 29 '05 #1
4 1565
no**@of.your.bi z.nes wrote:
Below is an old count-up script that displays ok in MSIE with a bit of
experimenting, but NS shows negative values that make no sense. Anyone
know how to make it work ok in both?
There have been two threads in the last few days on this, search for
getFullYear and sort by date.

"Date problem in Opera"
<URL:http://groups.google.c o.uk/group/comp.lang.javas cript/browse_frm/thread/3fad1afb8207408 b/5ff2ae7a62b8b31 9?q=getFullYear &rnum=1&hl=en#5 ff2ae7a62b8b319 >

"Who's fault: different displays of date"
<URL:http://groups.google.c o.uk/group/comp.lang.javas cript/browse_frm/thread/eff514c740a32ae 2/a5e8b6192b35b61 0?q=getFullYear &rnum=2&hl=en#a 5e8b6192b35b610 >
[...]
// These get the current year, month, and date

var thisyear = today.getYear()


Here's your problem ----------^^^^^^^

Use getFullYear(), but be aware that very old browsers will only support
getYear().

That caveat is added because if a date function misbehaves for any
reason, a visitor's confidence in your site is shaken - even a very
small number of failures may be unacceptable.

[...]

--
Rob
Sep 29 '05 #2
Lee
no**@of.your.bi z.nes said:
// Don't change these

// These get the current year, month, and date

var thisyear = today.getYear()


Change that to:

var thisyear = today.getFullYe ar();

Sep 29 '05 #3
Thursday September 29 2005 16:10, Lee wrote to All:
var thisyear = today.getYear()


L> Change that to:

L> var thisyear = today.getFullYe ar();

Thanks to all who replied. Works ok now.
KS

KARICO Business Services
Toronto, ON Canada
http://www.karico.ca

.... Sound and fury, signifying nothing.
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Sep 30 '05 #4
JRS: In article <Go************ *************** *@of.your.biz.n es>, dated
Thu, 29 Sep 2005 18:47:19, seen in news:comp.lang. javascript,
no**@of.your.bi z.nes <DA************ ******@your.bis .nes> posted :
Below is an old count-up script that displays ok in MSIE with a bit of
experimentin g, but NS shows negative values that make no sense. Anyone
know how to make it work ok in both?


DO NOT just change getYear to getFullYear; the code would be rubbish
even if it were not bloated, though the results may be correct most of
the time (I don't see allowance for Leap Years).

Code posted to News should be executable as is, which means that it
should not be wrapped by the posting process.

Read the newsgroup FAQ; see below.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Sep 30 '05 #5

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

Similar topics

1
4819
by: Allen | last post by:
I am trying to add an additional photo/hyperlink to the company web site (I didn't create it) without any luck. The mouseover feature 'highlights' pics by swapping them with another pic using this command in some type of array. I added the mailbox in the lower left corner (see link below)http://www.aamechanical.com/indextemp.htm but I cannot get it to swap. Here is the code for the page: Thanks for your help in advance
7
1637
by: David. E. Goble | last post by:
Hi all; I have the following files; index.html, sigsheader.js, sigsboby.js, smilesbody.js and smiles.js. The sourse is below. The page displays two manual slide shows... Each slideshow has a set of buttons. the top slideshow (the smiles work fine. How ever the sigs slideshow displays the pictures in the smiles section. *************** index.html ***************************** <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01...
62
3762
by: TheShadow1 | last post by:
safetyTips - this array is in here.js ...
55
4210
by: drhowarddrfine | last post by:
I'm working on a web site that could use some control using js but am concerned about what problems I may have with potential users having their js turned off. Has anyone had any serious problems with this sort of thing? I know some of these potential users are with big companies and am wondering if anyone had real problems with that.
9
1834
by: David. E. Goble | last post by:
Arrrh! some buttons work while others don't, but I can't see why. I have tried comparing the files that do work, with the ones that don't. But to no help. The funny thing is the parts that work have the same code, except different variables. (Note Javascript and htm code was writen by a c program, the code then run thru a html to js converter)
7
4443
by: sck10 | last post by:
Hello, I have the following sub in a class in my "App_Code" directory. The script is for setting focus on a particular control, but I get the error, "Name ClientScript Not declared". Also, I am using MasterPages. How do I use "ClientScript.RegisterStartupScript" in a class? Public Shared Sub SetFocusControl(ByVal FocusControl As Control) Dim Script As New System.Text.StringBuilder Dim ClientID As String = FocusControl.ClientID
1
1600
by: Neo Geshel | last post by:
I am having conflicting results with two pieces of identical code. One is an insert, the other is an update to a db. The first code, which works, is this: Sub Add3_Click(sender As Object, e As EventArgs) Dim imgStream as Stream = Add3Image.PostedFile.InputStream Dim imgLen as Integer = Add3Image.PostedFile.ContentLength Dim imgType as String = Add3Image.PostedFile.ContentType If Not imgStream Is Nothing And imgLen > 0 And (imgType =
10
3334
by: ellie2905 | last post by:
Hello, I am new to this forum and I am glad I found it because it seems that it will help me with my problem.I have creates a site using jsf components like grid panels and buttons.In the mozilla firefox browser the components are shown just as they are supposed to, but in internet explorer my button stretches to the right until the end of the page and two buttons that I have included on a grid panel, instead of being the one below the other, in...
1
47482
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click on a link and after a moment or two a file download dialog box pops-up in your web browser and prompts you for some instructions, such as “open” or “save“. I’m going to show you how to do that using a perl script. What You Need Any recent...
5
13379
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL http://mghospedagem.com/images/controlpanel.jpg instead of http://mghospedagem.comhttp://mghospedagem.com/images/controlpanel.jpg As u see, there's the website URL before the image URL.
0
9563
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10144
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9997
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9937
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8821
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6642
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5270
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3522
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.