INNER CODE UNIT · JavaScript

currentMinutes

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

  const currentMinutes = currentDate.getHours() * 60 + currentDate.getMinutes();
  const currentPeriod = currentSchedule[findCurrentPeriod(currentSchedule, currentMinutes)];
  const secondsRemaining = (currentPeriod.start + currentPeriod.long) * 60
    - (currentMinutes * 60 + currentDate.getSeconds());
  const isCountdownPeriod = currentPeriod.long > 30
    && /^(P[1-6]|A)$/.test(currentPeriod.name);
  const showSeconds = isCountdownPeriod
    && secondsRemaining > 0
    && secondsRemaining <= 60;
  const hours = (currentDate.getHours() - 1) % 12 + 1;
  const minutes = String(currentDate.getMinutes()).padStart(2, "0");
  const seconds = String(currentDate.getSeconds()).padStart(2, "0");

  return {
    text: `${hours}:${minutes}${showSeconds ? `:${seconds}` : ""}`,
    showSeconds
  };
}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…