Y2K bug ! Date().getYear() reports 103 instead of 2003

RESOLVED DUPLICATE of bug 22964

Status

()

Core
JavaScript Engine
--
major
RESOLVED DUPLICATE of bug 22964
15 years ago
13 years ago

People

(Reporter: Thibaut REGNIER, Assigned: rogerl (gone))

Tracking

Trunk
x86
Linux
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

(Reporter)

Description

15 years ago
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021130
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021130

I've just seen a page giving the age of someone using Javascript.
The age was - 1864 years.
This was a known bug in Netscape 4.x, but I thought it was fixed in Mozilla.

To see the bug, go the the Javascript console and type :
new Date().getYear()

=> it gives 103 instead of 2003.

This bug should be easy to fix.

Reproducible: Always

Steps to Reproduce:
1. Tools -> Web development -> JavaScript Console
2. Type: new Date().getYear()
3. Press Enter

Actual Results:  
103 is displayed

Expected Results:  
2003 should have been displayed (I'm writing this in Year 2003!)

Comment 1

15 years ago
This is as it should be, surprisingly enough.

Quoting Phil Schwartau:

"The upshot is d.getYear() was deprecated in the ECMA-262 standard 
in favor of d.getFullYear()

Here are various bugs with further information on this:

bug 22964
bug 45764 <--- particuarly see last comment in this one for the history of this 
bug 100123
bug 115264"

*** This bug has been marked as a duplicate of 45764 ***
Status: UNCONFIRMED → RESOLVED
Last Resolved: 15 years ago
Resolution: --- → DUPLICATE
Verified "make sure you know what you're talking about"
Status: RESOLVED → VERIFIED
(Reporter)

Comment 3

15 years ago
Thanks for the reference to
http://developer.netscape.com/viewsource/wyner_2k/wyner_2k.html

which explains a lot.

Returning more than 100 for years >2000 was considered a bug a few years ago,
and as the article explains I remenber seeing the getYear() returning "2000".
I didn't know the spec had changed back to what was considered a bug before...

My conclusion is that using getDate() is inapprorpriate, getFullYear() should
always be used.
Status: VERIFIED → CLOSED
(Reporter)

Comment 4

15 years ago
I meant :
My conclusion is that using getYear() is inapprorpriate, getFullYear() should
always be used.

Status: CLOSED → UNCONFIRMED
Resolution: DUPLICATE → ---

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