2021-09-12 22:40:30 +02:00

26 lines
1.4 KiB
JavaScript

<!--
// This function displays the time in the status line.
// Invoke it once to activate the clock; it will call itself from then on.
function display_time_in_status_line()
{
var mes = new Array( "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre" );
var d = new Date(); // month day, year hours:minutes:seconds
var y = d.getYear(); // get current year
var h = d.getHours(); // extract hours: 0 to 23
var m = d.getMinutes(); // extract minutes: 0 to 59
var s = d.getSeconds(); // extract seconds: 0 to 59
var mo = d.getMonth() + 1; // extract months: January to December
var da = d.getDate(); // extract days: 1 to 31
var ampm = (h >= 12)?"PM":"AM"; // is it am or pm?
if (h > 12) h -= 12; // convert 24-hour format to 12-hour
if (h == 0) h = 12; // convert 0 o'clock to midnight
if (m < 10) m = "0" + m; // convert 0 minutes to 00 minutes, etc.
var t = da + ' de ' + mes[mo-1] + ' de ' + y + ' | ' + h + ':' + m + ':' + s + ' ' + ampm; // put it all together
defaultStatus = t; // display it in the status line
// arrange to do it again in 1 second.
setTimeout("display_time_in_status_line()", 1000); // 1000 ms in 1 second
}
display_time_in_status_line();
//-->