INNER CODE UNIT · JavaScript

findCurrentPeriod

landgreen/landgreen.github.io · bells/index.js:1497

function findCurrentPeriod(b, minutes = todayMinutes) {
  // let period = 0;
  for (let i = 0, len = b.length; i < len; ++i) {
    if (minutes >= b[i].start && minutes < b[i].start + b[i].long) {
      return i;
    }
  }
  return b.length - 1;
}

function drawCurrentPeriod(b) {
  const period = b[findCurrentPeriod(b)];
  let startTime = {
    hour: Math.floor((period.start / 60 - 1) % 12 + 1),
    minute: period.start % 60
  };
  if (startTime.minute < 10) startTime.minute = "0" + startTime.minute; //add zero for single digit minutes
  let endTime = {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…