// Version 4.4 "use strict"; var days = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334], b_seconds_old = -1, lept_hand, minute_hand, second_hand, string; function draw_analogue_clock() { var angle = 0.0, arc = Math.PI / 2.0, canvas, centre = 125, colour = "#000000", cos, end_x, end_y, face_line, i, j, max = 4, pin, radius = 100, shrad = radius - 8, sin, start_x, start_y, twice = centre << 1; document.writeln('
'); canvas = new Raphael("clock_id", twice, twice); for (i = 0; i < 5; i++) { if (i > 0) { if (i > 1) { arc /= 2.0; max <<= 1; } angle = arc / 2.0; } for (j = 0; j < max; j++) { cos = Math.cos(angle); sin = Math.sin(angle); angle += arc; start_x = centre + Math.round(shrad * cos); start_y = centre + Math.round(shrad * sin); end_x = centre + Math.round(radius * cos); end_y = centre + Math.round(radius * sin); face_line = canvas.path("M" + start_x + " " + start_y + "L" + end_x + " " + end_y); face_line.attr({ "stroke": colour, "stroke-width": 1 }); } shrad++; } string = "M" + centre + " " + centre + "L" + centre + " "; lept_hand = canvas.path(string + "195"); lept_hand.attr({ "stroke": colour }); minute_hand = canvas.path(string + "210"); minute_hand.attr({ "stroke": colour }); second_hand = canvas.path(string + "216"); second_hand.attr({ "stroke": colour }); pin = canvas.circle(centre, centre, 2); pin.attr({ "stroke": colour }); string = "," + centre + "," + centre; } function update_clocks() { var now = new Date(), g_hours = now.getHours(), g_minutes = now.getMinutes(), g_seconds = now.getSeconds(), g_millisecs = now.getMilliseconds(), b_seconds = Math.round((g_hours * 3600 + g_minutes * 60 + g_seconds + g_millisecs / 1000.0) / 0.32958984375), g_year = now.getFullYear(), g_month = now.getMonth(), g_day = now.getDate(), b_day = (g_year % 4 === 0 && g_month > 1) ? g_day + days[g_month] : g_day + days[g_month] - 1, o_seconds = b_seconds.toString(8), t_seconds, d_seconds, g_time; if (b_seconds_old !== b_seconds) { b_seconds_old = b_seconds; o_seconds = "000000".substr(0, 6 - o_seconds.length) + o_seconds; document.getElementById('octal').value = g_year.toString(8) + "," + b_day.toString(8) + "." + o_seconds; t_seconds = b_seconds.toString(4); t_seconds = "000000000".substr(0, 9 - t_seconds.length) + t_seconds; document.getElementById('tetral').value = g_year.toString(4) + "," + b_day.toString(4) + "." + t_seconds; d_seconds = b_seconds.toString(2); d_seconds = "000000000000000000".substr(0, 18 - d_seconds.length) + d_seconds; document.getElementById('dual').value = g_year.toString(2) + "," + b_day.toString(2) + "." + d_seconds; g_month++; if (g_month < 10) { g_month = "0" + g_month; } if (g_day < 10) { g_day = "0" + g_day; } if (g_hours < 10) { g_hours = "0" + g_hours; } if (g_minutes < 10) { g_minutes = "0" + g_minutes; } if (g_seconds < 10) { g_seconds = "0" + g_seconds; } g_time = g_day + "." + g_month + "." + g_year + " " + g_hours + ":" + g_minutes + ":" + g_seconds; document.getElementById('greg').value = g_time; lept_hand.transform("r" + Math.round(b_seconds * 0.001373291015625) + string); minute_hand.transform("r" + Math.round(b_seconds % 4096 * 0.087890625) + string); second_hand.transform("r" + Math.round(b_seconds % 64 * 5.625) + string); } setTimeout('update_clocks();', 100); } function write_form() { var date, expression; document.writeln('

'); document.writeln('
'); document.writeln('
'); document.writeln('
'); draw_analogue_clock(); update_clocks(); document.writeln('
'); document.writeln('
'); document.writeln(''); if (window.location.href.lastIndexOf('date=') > 0) { expression = /(^[\w\W]*date=([\w\W]*)$)/g; if (expression.test(window.location.href)) { expression.exec(window.location.href); date = RegExp.$1; expression = /(^(0[1-9]|[1-3]\d)\.(0[1-9]|1[0-2])\.([1-3]\d{3})$)/g; if (expression.test(date)) { document.getElementById('date').value = date; } } window.document.forms[1].scrollIntoView(true); } } function convert_date() { var i, inc, j, number = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], weekday = ["Sunday", "Earthday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], value = document.getElementById('date').value, expression = /(0[1-9]|[1-3]\d)\.(0[1-9]|1[0-2])\.([1-3]\d{3})/g, cell, date, day, month, week, year, o_mon, Window; if (expression.test(value)) { expression.exec(value); date = RegExp.$3 + RegExp.$2 + RegExp.$1; day = Number(RegExp.$1); month = Number(RegExp.$2) - 1; year = Number(RegExp.$3); inc = (year % 4 === 0) ? (year % 400 !== 0 && year % 100 === 0) ? 0 : 1 : 0; if (date >= '15821015' && (day <= number[month] || (month === 1 && day <= number[month] + inc))) { day += (month > 1) ? days[month] + inc : days[month]; o_mon = --day >> 5; Window = window.open("bh_en_octal_calendar.html", "Window1", "width=400, height=315, left=600, top=250, resizable=yes"); Window.focus(); Window.document.writeln(''); Window.document.writeln(''); Window.document.writeln(''); Window.document.writeln(''); Window.document.writeln('"); Window.document.writeln('Octal calendar'); Window.document.writeln(''); Window.document.writeln(''); Window.document.writeln(''); Window.document.writeln(''); Window.document.writeln(''); Window.document.writeln(''); Window.document.writeln(''); Window.document.writeln(''); Window.document.writeln(''); Window.document.writeln('\n\n
'); Window.document.writeln('\n'); Window.document.writeln(''); for (j = 0; j < 4; j++) { week = ((o_mon << 2) + j).toString(8); Window.document.writeln(''); } Window.document.writeln('\n\n'); for (i = 0; i < 8; i++) { Window.document.writeln(''); for (j = 0; j < 4; j++) { cell = (o_mon << 5) + (j << 3) + i; if (cell === day) { Window.document.writeln(''); } else { if (cell < 365 + inc) { Window.document.writeln(''); } else { Window.document.writeln(''); } } } Window.document.writeln(''); } Window.document.writeln('
' + months[o_mon] + "
" + year.toString(8) + '
' + "Week
" + week + '
' + weekday[i] + '' + "→" + cell.toString(8) + "←" + '' + cell.toString(8) + ' 
\n

'); Window.document.writeln('
'); Window.document.forms[0].close.focus(); } else { alert("The date is unfortunately not valid."); } } else { alert("The date is unfortunately not valid."); } } write_form();