function cvts(n) {
// converts number 1 - 4999 to a subtractive Roman numeral ...
return (cvt1000(n) + cvt100s(n) + cvt10s(n) + cvt1s(n))
}
function cvt1000(n) {
// converts thousands digit to a Roman numeral ...
return ('MMMM'.substr(0, (Math.floor(n / 1000))));
}
function cvt100s(h) {
// converts hundreds digit to a subtractive Roman numeral ...
var m = '', h = Math.floor((h % 1000) / 100);
if (h == 9) {m = 'CM'}
else if (h > 4) {m = 'DCCC'.substr(0, h - 4)}
else if (h == 4) {m = 'CD'}
else {m = 'CCC'.substr(0, h)};
return m;
}
function cvt10s(t) {
// converts tens digit to a subtractive Roman numeral ...
var m = '', t = Math.floor((t % 100) / 10);
if (t == 9) {m = 'XC'}
else if (t > 4) {m = 'LXXX'.substr(0, t - 4)}
else if (t == 4) {m = 'XL'}
else {m = 'XXX'.substr(0, t)};
return m;
}
function cvt1s(u) {
// converts units digit to a subtractive Roman numeral ...
var m = '', u = u % 10;
if (u == 9) {m = 'IX'}
else if (u > 4) {m = 'VIII'.substr(0, u - 4)}
else if (u == 4) {m = 'IV'}
else {m = 'III'.substr(0, u)};
return m;
}
/////////////// Date conversion ...
// declare constants ...
var Lday = new Array('Dominica', 'Lun\xE6', 'Martis', 'Mercurii', 'Iovis', 'Veneris', 'Sambati');
var Lmth = new Array('Januarii', 'Februarii', 'Martii', 'Aprilis', 'Maii', 'Junii', 'Julii', 'Augusti', 'Septembris', 'Octobris', 'Novembris', 'Decembris');
var Rday = new Array('SOLIS', 'LVN\xC6', 'MARTIS', 'MERCVRII', 'IOVIS', 'VENERIS', 'SATVRNI');
var Rmth = new Array('IANVARIAS', 'FEBRVARIAS', 'MARTIAS', 'APRILES', 'MAIAS', 'IVNIAS', 'IVLIAS', 'AVGVSTAS', 'SEPTEMBRES', 'OCTOBRES', 'NOVEMBRES', 'DECEMBRES');
var Rmth2 = new Array('IANVARIIS', 'FEBRVARIIS', 'MARTIIS', 'APRILIBVS', 'MAIIS', 'IVNIIS', 'IVLIIS', 'AVGVSTIS', 'SEPTEMBRIBVS', 'OCTOBRIBVS', 'NOVEMBRIBVS', 'DECEMBRIBVS');
var today, D, M, Y, msg = '';
// get today's date ...
D = 5; //number of the day
A = 0; //day of the week
M = 2; //number of the month
Y = 2012; //number of the year
var day = A, rd, RY = Y + 753; //if (JM == 12 && JD > 13) {RY ++};
if (M == 3 || M == 5 || M == 7 || M == 10) {rd = RD(D, M, 7, 15, 31)}
else if (M == 1 || M == 8 || M == 12) {rd = RD(D, M, 5, 13, 31)}
else if (M == 4 || M == 6 || M == 9 || M == 11) {rd = RD(D, M, 5, 13, 30)}
else if (Y % 4 == 0 && Y % 400 != 0) {rd = leapFeb(D)}
else {rd = RD(D, M, 5, 13, 28)};
roman = 'DIE '+Rday[day] + ' ' + rd + ' ' + cvts(RY) + ' A.V.C.';
roman2 = Lday[day] + ' die' + '
' + '' + cvts(D).toLowerCase()+ 'a' + ' ' + Lmth[M - 1] + ' m. ' + '' + cvts(Y).toLowerCase()+'o';
function RD(JD, JM, NON, ID, PKAL) {
// returns string with date in Roman format (except for leap February) ...
var rd;
if (JD == 1) {rd = 'KALENDIS ' + Rmth2[JM - 1]}
else if (JD < NON - 1) {rd = 'A. D. ' + cvts(NON + 1 - JD) + ' NONAS ' + Rmth[JM - 1]}
else if (JD == NON - 1) {rd = 'PRIDIE NONAS ' + Rmth[JM - 1]}
else if (JD == NON) {rd = 'NONIS ' + Rmth2[JM - 1]}
else if (JD < ID - 1) {rd = 'A. D. ' + cvts(ID + 1 - JD) + ' IDVS ' + Rmth[JM - 1]}
else if (JD == ID - 1) {rd = 'PRIDIE IDVS ' + Rmth[JM - 1]}
else if (JD == ID) {rd = 'IDIBVS ' + Rmth2[JM - 1]}
else if (JD < PKAL) {rd = 'A. D. ' + cvts(PKAL + 2 - JD) + ' KALENDAS ' + Rmth[JM % 12]}
else {rd = 'PRIDIE KALENDAS ' + Rmth[JM % 12]};
return rd;
}
function leapFeb(JD) {
// returns string with date in Roman format for leap February ...
var rd;
if (JD == 1) {rd = 'KALENDIS FEBRVARIIS'}
else if (JD < 4) {rd = 'A. D. ' + cvts(6 - JD) + ' NONAS FEBRVARIAS'}
else if (JD == 4) {rd = 'PRIDIE NONAS FEBRVARIAS'}
else if (JD == 5) {rd = 'NONIS FEBRVARIIS'}
else if (JD < 12) {rd = 'A. D. ' + cvts(14 - JD) + ' IDVS FEBRVARIAS'}
else if (JD == 12) {rd = 'PRIDIE IDVS FEBRVARIAS'}
else if (JD == 13) {rd = 'IDIBVS FEBRVARIIS'}
else if (JD < 25) {rd = 'A. D. ' + cvts(30 - JD) + ' KALENDAS MARTIAS'}
else if (JD == 25) {rd = 'BIS VI KALENDAS MARTIAS'}
else if (JD < 29) {rd = 'A. D. ' + cvts(31 - JD) + ' KALENDAS MARTIAS'}
else {rd = 'PRIDIE KALENDAS MARTIAS'};
return rd;
}