Closed Bug 192241 Opened 22 years ago Closed 20 years ago

y2k bug in date.getYear()

Categories

(Core :: JavaScript Engine, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 22964

People

(Reporter: sean.mozilla, Assigned: rogerl)

Details

User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3a) Gecko/20021212
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3a) Gecko/20021212

date gets reported as 103 instead of 2003



Reproducible: Always

Steps to Reproduce:
<script>
today = new Date();
yearVal = today.getYear();
alert(yearVal);
</script>
Actual Results:  
result is 103

Expected Results:  
result of 2003 or 03
yup :) (2003020511)
Status: UNCONFIRMED → NEW
Ever confirmed: true
Oh, new variant of this INVALID bug. getYear() method is behaving according to
spec. (see ECMA Edition 3, 13 October 1999 - Section B.2.4) -- it SHOULD return
03 for 2003.


*** This bug has been marked as a duplicate of 45764 ***

*** This bug has been marked as a duplicate of 45764 ***
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → DUPLICATE
but! if looked up the 'official' specs:

http://developer.netscape.com/docs/manuals/js/core/jsref/date.htm#1194138:

getYear is no longer used and has been replaced by the getFullYear method.

The getYear method returns the year minus 1900; thus:

    * For years above 2000, the value returned by getYear is 100 or greater. For
example, if the year is 2026, getYear returns 126.

    * For years between and including 1900 and 1999, the value returned by
getYear is between 0 and 99. For example, if the year is 1976, getYear returns 76.

    * For years less than 1900 or greater than 1999, the value returned by
getYear is less than 0. For example, if the year is 1800, getYear returns -100.

To take into account years before and after 2000, you should use
Date.getFullYear instead of getYear so that the year is specified in full.

so this is INVALID.
Resolution: DUPLICATE → INVALID
This is a dupe of an invalid bug. Reopening to dupe.
Status: RESOLVED → REOPENED
Resolution: INVALID → ---

*** This bug has been marked as a duplicate of 100123 ***
Status: REOPENED → RESOLVED
Closed: 22 years ago22 years ago
Resolution: --- → DUPLICATE
Verified Duplicate.

See bug 45764 for the history of this method, and how Mozilla and
Microsoft came to differ on its behavior. 

At any rate, the method to use is getFullYear().
Status: RESOLVED → VERIFIED
Status: VERIFIED → REOPENED
Resolution: DUPLICATE → ---

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