JSFiddle - React, Tailwind, and code Playground
HTML
<span id="years"></span>
<span id="months"></span>
<span id="date"></span>
<span id="hours"></span>
<span id="minutes"></span>
<span id="acbc"></span>
JavaScript
function BigDate (date) {
this.original = date;
}
// first "eliminate" seconds and milliseconds
BigDate.prototype.getMilliseconds = function() {
return 0;
}
BigDate.prototype.getSeconds = function() {
return 0;
}
// then set all other methods but year, seconds and, milliseconds
BigDate.prototype.getMinutes = function () {
return this.original.getMinutes();
}
BigDate.prototype.getHours = function () {
return this.original.getHours();
}
BigDate.prototype.getDate = function () {
return this.original.getDate();
}
BigDate.prototype.getMonth = function () {
return this.original.getMonth();
}
// now return positive year
BigDate.prototype.getFullYear = function () {
var ms = this.original.getSeconds() * 1000 + this.original.getMilliseconds();
var result;
if (ms === 0)
result = this.original.getFullYear();
else
result = (ms * 240000) - this.original.getFullYear() - 1970;
return result;
}
// now add AC/BC method
BigDate.prototype.isAC = function () {
var ms = this.original.getSeconds() * 1000 + this.original.getMilliseconds();
var result;
if (ms === 0)
result = true;
else
result = false;
return result;
}
var years = document.getElementById("years");
var months = document.getElementById("months");
var date = document.getElementById("date");
var hours = document.getElementById("hours");
var minutes = document.getElementById("minutes");
var acbc = document.getElementById("acbc");
// SET A TIME AND PRESENT IT
var time = new Date (2016, 1, 28, 8, 21, 0, 0);
var bigDate = new BigDate(time);
var monthsName = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
years.innerHTML = bigDate.getFullYear();
months.innerHTML = monthsName[bigDate.getMonth() - 1];
date.innerHTML = bigDate.getDate();
hours.innerHTML = bigDate.getHours() + ":";
minutes.innerHTML = bigDate.getMinutes();
acbc.innerHTML = (bigDate.isAC()) ? "AC":"BC";