I am attempting to make a clock that is sped up for a world building game. I intend to have to clock start at the year 2104. I have tried negating a date I created in 2014 to the current date and time, multiplied the difference by 52.1429 (number of weeks in a year), and
var clock = {};
var yr2104 = new Date(2104, 0, 0, 0, 0, 0, 0);
var week = ['MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT', 'SUN'];
var timerID = setInterval(updateTime, 10);
updateTime();
function updateTime() {
_now = Date.now();
_diff = _now - (yr2104.getTime())
cd = new Date(yr2104.getTime() + (_diff * 52.1429))
clock.time = zeroPadding(cd.getHours(), 2) + ':' + zeroPadding(cd.getMinutes(), 2) + ':' + zeroPadding(cd.getSeconds() + "s", 3);
clock.date = zeroPadding(cd.getFullYear(), 4) + '-' + zeroPadding(cd.getMonth() + 1, 2) + '-' + zeroPadding(cd.getDate(), 2) + ' ' + week[cd.getDay()];
console.log(clock);
};
function zeroPadding(num, digit) {
var zero = '';
for (var i = 0; i < digit; i++) {
zero += '0';
}
return (zero + num).slice(-digit);
}
added that number to the old time. For some reason it does not start in the year 2104. What should I do? Could it be that the fact that subtracting the current time from the year 2104 gives a negative value?