Closed
Bug 282371
Opened 20 years ago
Closed 20 years ago
the getDate function is off by 1900
Categories
(Firefox :: Shell Integration, defect)
Tracking
()
People
(Reporter: unknown10566, Assigned: bugs)
Details
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; AOL 9.0; Windows NT 5.1; {EEEA9668-734D-417A-A997-5E8B9F175D64}; .NET CLR 1.0.3705)
Build Identifier: Mozilla Firefox 1.0
when you try to get the date in java script you have to add 1900 to the year
Reproducible: Always
Steps to Reproduce:
1. copy the following into a text document and then save it as a html document
---START COPYING---
<html>
<head>
<script src="events.js">
</script>
</head>
<body>
<script>
function isLeapYear(Y)
{ if ((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0)
{ leapYear = true;
}
else
{ leapYear = false;
}
}
function openRow()
{
document.write('<tr>');
}
function closeRow()
{
document.write('</tr>');
}
function openCell(height)
{
document.write('<td height="',height,'" valign="top">');
}
function closeCell()
{
document.write('</td>');
}
function dn(n)
{
document.write('<td align="center" width="14%">',n,'</td>');
}
function cal(mnth,Y,width,events)
{
var daysInMonth = new Array();
var nameOfMonth = new Array();
daysInMonth[0] = 31 ;
nameOfMonth[0] = "January";
daysInMonth[1] = 28;
nameOfMonth[1] = "Febuary";
daysInMonth[2] = 31;
nameOfMonth[2] = "March";
daysInMonth[3] = 30;
nameOfMonth[3] = "April";
daysInMonth[4] = 31;
nameOfMonth[4] = "May";
daysInMonth[5] = 30;
nameOfMonth[5] = "June";
daysInMonth[6] = 31;
nameOfMonth[6] = "July";
daysInMonth[7] = 31;
nameOfMonth[7] = "August";
daysInMonth[8] = 30;
nameOfMonth[8] = "September";
daysInMonth[9] = 31;
nameOfMonth[9] = "October";
daysInMonth[10] = 30;
nameOfMonth[10] = "November";
daysInMonth[11] = 31;
nameOfMonth[11] = "December";
myDate = new Date();
myDate.setDate(1);
myDate.setMonth(mnth - 1);
fdw = myDate.getDay();
lastDay = daysInMonth[mnth-1];
if(mnth == 2 && isLeapYear(Y))
{
lastDay = 29
}
// document.write(myDate,'f: ',fdw,'<br>'); For Debug
document.write('<table border="9" width="', width, '" ><tr><td colspan="7"
align="center">');
document.write(nameOfMonth[mnth-1],' ',Y);
rh = width*3/4/6;
document.write('</td> </tr>');
document.write('<tr>');
dn('Sun');
dn('Mon');
dn('Tue');
dn('Wed');
dn('Thu');
dn('Fri');
dn('Sat');
document.write('</tr>');
var ed =1;
var dom = 1;
for (week =0;week<6 && dom < lastDay;week++)
{
openRow();
for (wd =0;wd <7;wd++)
{
openCell(rh);
if (ed++ <=fdw)
{
document.write(' ');
continue;
}
if (dom <=lastDay)
{
if (curdate.getDate() == dom && curdate.getMonth()+1 == mnth )
{
document.write('<h4>',dom,'</h4>')
}
else
{
document.write(dom,'<br>');
}
if ( events && events[dom] )
{
document.write(events[dom]);
}
++dom;
}
else
{
document.write(' ');
}
closeCell();
}
closeRow();
}
document.write('</table>');
}
var curdate = new Date ();
var month = curdate.getMonth();
myYear = curdate.getYear();
//document.write(curdate,' ',curdate.getDay()); //For Debug
//cal(month,myYear,800,event);
month = 1
document.write('<table>');
for (r = 0 ;r< 4;r++)
{
document.write('<tr>');
for (c = 0;c<3 ;c++)
{
document.write('<td>');
//document.write('<table><tr><td>x</td></tr></table>');
cal(month++,myYear,100);
document.write('</td>');
}
document.write('</tr>');
}
document.write('</table>');
/*
if ((/4 && !/100) || if /400)
*/
document.write(Math.random);
</script>
</body>
</html>
---STOP copying---
2. open it in FIREFOX 1.0
Actual Results:
the year was displayed as being 105
Expected Results:
The expected result was for the year to be displayed as 2005
Yes I checked the date on my computer and its said it was 2005 {Win Xp is the
OS I'm using}
Comment 1•20 years ago
|
||
That's actually the correcct behaviour. You probably want to use getFullYear(), which gives the same result in Mozilla and Internet Exploder. *** This bug has been marked as a duplicate of 22964 ***
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → DUPLICATE
Updated•20 years ago
|
Status: RESOLVED → VERIFIED
You need to log in
before you can comment on or make changes to this bug.
Description
•