Closed Bug 296031 Opened 20 years ago Closed 17 years ago

thanhniennews.com - javascript date calculation off by 100 years: getYear function

Categories

(Tech Evangelism Graveyard :: English Other, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: martin.althoff, Unassigned)

References

()

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4

The link shows on top of page:  Last Updated: Tuesday, May 31, 2105 12:04:38
Vietnam (GMT+07). The year is 100 years of. Looking at page source, the
variables seem initialized correctly. It seems the getyear function extracts
something wrong?

Reproducible: Always

Steps to Reproduce:
just look at the website, date string is at top centre



Expected Results:  
show the year as 2005
From site:

if (todaysDate.getYear() < 1000){ 
  document.write(todaysDate.getYear() + 2000); 
} else { 
  document.write(todaysDate.getYear());
}

According to the ECMAScript spec, getYear returns: current year - 1900, so they
should either add 1900 instead of 2000 or even better use getFullYear.

->Tech Evangelism
Assignee: nobody → english-other
Component: General → English Other
OS: Windows XP → All
Product: Firefox → Tech Evangelism
QA Contact: general → english-other
Hardware: PC → All
Summary: javascript date calculation off by 100 years: getYear function → thanhniennews.com - javascript date calculation off by 100 years: getYear function
The problematic code is commented out. The printed line now shows the real year browserwide.
Status: UNCONFIRMED → RESOLVED
Closed: 17 years ago
Resolution: --- → WORKSFORME
Product: Tech Evangelism → Tech Evangelism Graveyard
You need to log in before you can comment on or make changes to this bug.