home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
207.233.110.77
/
207.233.110.77.tar
/
207.233.110.77
/
web31
/
Section_78401
/
Students
/
Eskenas_Alan
/
tutorial.10
/
case1
/
datetime.js
next >
Wrap
Text File
|
2011-11-22
|
1KB
|
37 lines
/*
New Perspectives on HTML and XHTML 5th Edition
Tutorial 10
Case Problem 1
Function List:
showDate
Used to return a text string containing the current date and time.
getMap
Used to the determine the current sky map number to display with the online planisphere
*/
function showDateTime() {
var thisDate = new Date();
var thisWDay=thisDate.getDay();
var thisDay=thisDate.getDate();
var thisMonth=thisDate.getMonth();
var thisYear=thisDate.getFullYear();
var mName = new Array("January", "February", "March", "April", "May",
"June", "July", "August", "September", "October","November", "December");
var hours=thisDate.getHours();
var minutes=thisDate.getMinutes();
ampm = hours >=12 ? " pm" : " am";
hours = hours > 12 ? hours-12 : hours;
minutes = minutes < 10 ? "0"+minutes : minutes;
return mName[thisMonth]+" "+thisDay+", "+thisYear + ", " + hours + ":" + minutes + ampm;
}
function getMap() {
thisTime = new Date();
hour = thisTime.getHours();
month = thisTime.getMonth();
mapNumber = (month*2+hour)%24;
return mapNumber;
}