Node.js examples for Object:Object Operation
Create Date Time class
function ExoDateTime() { }; ExoDateTime.prototype.getTime = function() { var dateTime = new Date() ; var hour = dateTime.getHours() ; var minute = dateTime.getMinutes() ; var second = dateTime.getSeconds() ; if (hour <= 9) hour = "0" + hour ; if (minute <= 9) minute = "0" + minute ; var AM_PM = "" ; if (hour < 12) { AM_PM = "AM" ; } else if (hour == 12) { AM_PM = "PM" ; } else {//from ww w. java 2 s . co m AM_PM = "PM" ; hour = hour - 12 ; } var time = "" ; time += hour + ":" + minute + " " + AM_PM ; var digitalClock = document.getElementById("DigitalClock") ; digitalClock.innerHTML = time ; setTimeout("eXo.core.ExoDateTime.getTime()", 60000) ; } ; ExoDateTime.prototype.getDate = function() { var dateTime = new Date() ; var date = dateTime.getDate() ; var month = dateTime.getMonth() ; var year = dateTime.getFullYear() ; if(date <= 9) date = "0" + date ; switch(month) { case 0: month = "Jan" ; break ; case 1: month = "Feb" ; break ; case 2: month = "Mar" ; break ; case 3: month = "Apl" ; break ; case 4: month = "May" ; break ; case 5: month = "Jun" ; break ; case 6: month = "Jul" ; break ; case 7: month = "Aug" ; break ; case 8: month = "Sep" ; break ; case 9: month = "Oct" ; break ; case 10: month = "Nov" ; break ; case 11: month = "Dec" ; break ; default: month = month ; break ; } var today = date + " " + month + " " + year ; var dateElement = eXo.core.DOMUtil.findFirstDescendantByClass(document.body, "div", "Date") ; dateElement.innerHTML = today ; }; eXo.core.ExoDateTime = new ExoDateTime() ;