Today, I made a small addition to this blog: A small widget, that shows the current challenge status.

Check it out on the homepage.

It displays finished projects, time until next has to be published and a jokers counter.

The code for calculating the time until the next project needs to be published, if you’re interested:

const deadlineHourUTC = 10;
const dayInMilliseconds = 1000 * 60 * 60 * 24;
const dateNow = new Date();
let targetDate = Date.UTC(
  dateNow.getUTCFullYear(),
  dateNow.getUTCMonth(),
  dateNow.getUTCDate(),
  deadlineHourUTC
);
if (dateNow.getUTCHours() > deadlineHourUTC) targetDate += dayInMilliseconds;

const minutesUntil = Math.floor(
  Math.abs(targetDate - dateNow.getTime()) / (1000 * 60)
);

const hours = Math.floor(minutesUntil / 60);
const minutes = minutesUntil % 60;