Closed Bug 279128 Opened 20 years ago Closed 20 years ago

getYear function returns invalid year

Categories

(Firefox :: General, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 22964

People

(Reporter: mszleminski, Assigned: bugzilla)

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

Running the following code:

<html>
<head>
</head>
<body>
<SCRIPT language="JavaScript">
today = new Date();
data = new Date (today.getTime() + 432000000);
rok = (data.getYear() - 2000) * 3;
srok = new String(rok);
if (srok.length == 1) srok = '0' + srok;
mies = (data.getMonth() + 1) * 4;
smies = new String(mies);
if (smies.length == 1) smies = '0' + smies;
dzien = data.getDate() * 5;
sdzien = new String(dzien);
if (sdzien.length == 1) sdzien = '0' + sdzien;
numbers = srok + smies + sdzien;
document.write("5 days ahead of today will be " + data.getYear() + "-" +
(data.getMonth() + 1) + "-" + data.getDate() + " which encodes to " + numbers +
"<br><br>");
}
</script>
</body>

seems like getYear returns 105 instead of 2005.

Reproducible: Always

Steps to Reproduce:
1. Paste the code above into a file
2. Run file in Firefox
3. Run file in IE (works fine)

Actual Results:  
Saw webpage with invalid data

Expected Results:  
Evaluated correctly

about:buildconfig

Build platform
target
i686-pc-cygwin

Build tools
Compiler 	Version 	Compiler flags
$(CYGWIN_WRAPPER) cl 	12.00.8804 	-TC -nologo -W3 -nologo -Gy -Fd$(PDBFILE)
$(CYGWIN_WRAPPER) cl 	12.00.8804 	-TP -nologo -W3 -nologo -Gy -Fd$(PDBFILE)

Configure arguments
--disable-ldap --disable-mailnews
--enable-extensions=cookie,xml-rpc,xmlextras,pref,transformiix,universalchardet,webservices,inspector,gnomevfs,negotiateauth
--enable-crypto --disable-composer --enable-single-profile
--disable-profilesharing --enable-optimize --disable-debug --disable-tests
--enable-static --disable-shared --enable-official-branding
 ------- Additional Comment #1 From Tim Powell  2001-09-17 11:59 PST  [reply]
-------

This is expected behavior for backward compatibility with Netscape 4.x. You
should use today.getFullYear() instead. getFullYear returns the 4-digit year as
desired.

*** This bug has been marked as a duplicate of 100123 ***
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → DUPLICATE
Status: RESOLVED → UNCONFIRMED
Resolution: DUPLICATE → ---

*** This bug has been marked as a duplicate of 22964 ***
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago20 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.