Closed Bug 280319 Opened 21 years ago Closed 21 years ago

Bad day counter in JavaScript

Categories

(Firefox :: General, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

VERIFIED DUPLICATE of bug 22964

People

(Reporter: grzegorj, Assigned: bugzilla)

References

()

Details

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; pl-PL; rv:1.7.5) Gecko/20041108 Firefox/1.0 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; pl-PL; rv:1.7.5) Gecko/20041108 Firefox/1.0 In the right frame there is such a script: <SCRIPT TYPE="text/javascript"> <!-- var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"); function countup(yr,m,d) { var today=new Date(); var todayy=today.getYear(); var todaym=today.getMonth(); var todayd=today.getDate(); var todaystring=montharray[todaym]+" "+todayd+", "+todayy; var paststring=montharray[m-1]+" "+d+", "+yr; var difference=(Math.round((Date.parse(todaystring)-Date.parse(paststring))/(24*60*60*1000))*1); difference+="</B> dni!<BR>"; document.write("Witryna założona 18 czerwca 2002 roku, istnieje już <B>"+difference); } countup(2002,06,18); //--> </SCRIPT> It leads to bad results in Mozilla and Mozilla Firefox. Interesingly that the script works properly in Opera (and of course in MSIE). The text as seen in the browser is: "Witryna założona 18 czerwca 2002 roku, istnieje już -693005 dni!", it means "the website is created on 18th June 2002, it has already existed ... days" Reproducible: Always Steps to Reproduce: 1. See Details above. 2. 3. Actual Results: See Details above. Expected Results: It should show the correct number of days like Opera or MSIE do. The bug is configuration-independent.
Read bug 22964, comment 2 for an explanation why getYear return 105 and not 2005 use getFullYear() instead. *** This bug has been marked as a duplicate of 22964 ***
Status: UNCONFIRMED → RESOLVED
Closed: 21 years ago
Resolution: --- → DUPLICATE
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.