function vl_get_date_suffix(d) { switch(d) { case 1: case 21: return 'st'; case 2: case 22: return 'nd'; case 3: case 23: return 'rd'; default: return 'th'; } } function vl_get_date(julian_date=null) { const vl_zero_year = -4004; const vl_months = [ { key: 'ksh', display: 'Kushim' }, { key: 'glg', display: 'Gilgamesh' }, { key: 'mos', display: 'Moses' }, { key: 'set', display: 'Setanta' }, { key: 'khu', display: 'Khutulun' }, { key: 'tzo', display: 'Takezo' }, { key: 'lvl', display: 'Lovelace' }, { key: 'bch', display: 'Bach' }, { key: 'gha', display: 'Ghandi' }, { key: 'klo', display: 'Kahlo' }, { key: 'x', display: 'X' }, { key: 'mrc', display: 'Mercury' }, { key: 'svg', display: 'Savage' } ]; // flamboyance magnetism boldness rightness risk schemes stability // patience vengeance vision adaptability potential precision // devotion opportunism personas intensity skeptecism rationality // autonomy pride serenity vigilance wit efficiency spontaneity // kushim, // 3400 bc // gilgamesh, // 2800 bc // moses, // 2448 bc // cuchulainn, // ulster cycle, 1st century ad // musa, // 1280 ad // khutulun 1260ad // takezo, // 1584 ad // lovelace, // 1815 ad // beethoven, // 1823 ad // ghandi, // 1869 ad // kahlo, // 1907 ad // x, // 1925 ad // pele, // 1940 ad // mercury, // 1946 ad // savage, // 1952 ad const today = julian_date === null ? new Date() : new Date(julian_date.split('-')[0], julian_date.split('-')[1]-1, julian_date.split('-')[2]); const today_month = today.getMonth(); const today_date = today.getDate(); let today_year = today.getYear(); console.info('new today', today_date, today_month, today_year); let leap = false; if(today_year < 2000) { today_year += 1900 } if((today_year % 4 == 0 && today_year % 100 !=0) || today_year % 400 == 0) { leap = true } const month_sum = new Array(0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334) let day_of_year = today_date + month_sum[today_month]; if(leap && today_month > 1) { ++day_of_year } const vl_month = vl_months[parseInt((day_of_year+27)/28) - 1]; const vl_weekdays = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday") const vl_weekday = vl_weekdays[day_of_year % 7]; let vl_date = day_of_year % 28; if(vl_date == 0) { vl_date = 28 }; const vl_year = today_year - vl_zero_year; let vl_cal; if(day_of_year < 365) { vl_cal = vl_weekday + ", " + vl_month.display + " " + vl_date + vl_get_date_suffix(vl_date) + ", " + vl_year + "."; } else { if(day_of_year >= 365) { vl_cal = !leap ? "The Remainder, " + vl_year + "." : "The Remainder Supreme, " + vl_year + "."; }; }; console.debug('Date => julian:', today); console.debug('Date => julian_date:', today_date); console.debug('Date => julian_month:', today_month); console.debug('Date => julian_year:', today_year); console.debug('Date => julian_leap:', leap); console.debug('Date => day_of_year:', day_of_year); console.debug('Date => vl_weekday:', vl_weekday); console.debug('Date => vl_date:', vl_date); console.debug('Date => vl_month:', vl_month); console.debug('Date => vl_year:', vl_year); return vl_cal; } function vl_output_date(julian_date) { const date = vl_get_date(julian_date); const output = julian_date ? '
That day is:
' : 'Today is
'; document.getElementById('output').innerHTML = output + '