<commit_before>var m = require('mithril');
var opposite = require('chessground/util').opposite;

module.exports = function(ctrl) {
  var node = ctrl.vm.node, clock = node.clock;
  if (!clock && clock !== 0) return;
  var parentClock = ctrl.tree.getParentClock(node, ctrl.vm.path);
  var whiteCentis, blackCentis;
  var isWhiteTurn = node.ply % 2 === 0;
  if (isWhiteTurn) {
    whiteCentis = parentClock;
    blackCentis = clock;
  }
  else {
    whiteCentis = clock;
    blackCentis = parentClock;
  }
  var whitePov = ctrl.bottomColor() === 'white';
  var whiteEl = renderClock(whiteCentis, isWhiteTurn);
  var blackEl = renderClock(blackCentis, !isWhiteTurn);

  return m('div.aclocks', whitePov ? [blackEl, whiteEl] : [whiteEl, blackEl]);
}

function renderClock(centis, active) {
  return m('div', {
    class: 'aclock ' + (active ? ' active' : '')
  }, clockContent(centis));
}

function clockContent(centis) {
  if (centis === null) return '-';
  var date = new Date(centis * 10);
  var millis = date.getUTCMilliseconds();
  var sep = ':';
  var baseStr = pad2(date.getUTCMinutes()) + sep + pad2(date.getUTCSeconds());
  if (centis >= 360000) {
    var hours = Math.floor(centis / 360000);
    return hours + sep + baseStr;
  }
  var tenthsStr = Math.floor(millis / 100).toString();
  return [
    baseStr,
    m('tenths', '.' + tenthsStr)
  ];
}

function pad2(num) {
  return (num < 10 ? '0' : '') + num;
}<commit_msg>better render null clock<commit_after>var m = require('mithril');
var opposite = require('chessground/util').opposite;

module.exports = function(ctrl) {
  var node = ctrl.vm.node, clock = node.clock;
  if (!clock && clock !== 0) return;
  var parentClock = ctrl.tree.getParentClock(node, ctrl.vm.path);
  var whiteCentis, blackCentis;
  var isWhiteTurn = node.ply % 2 === 0;
  if (isWhiteTurn) {
    whiteCentis = parentClock;
    blackCentis = clock;
  }
  else {
    whiteCentis = clock;
    blackCentis = parentClock;
  }
  var whitePov = ctrl.bottomColor() === 'white';
  var whiteEl = renderClock(whiteCentis, isWhiteTurn);
  var blackEl = renderClock(blackCentis, !isWhiteTurn);

  return m('div.aclocks', whitePov ? [blackEl, whiteEl] : [whiteEl, blackEl]);
}

function renderClock(centis, active) {
  return m('div', {
    class: 'aclock ' + (active ? ' active' : '')
  }, clockContent(centis));
}

function clockContent(centis) {
  if (!centis && centis !== 0) return '-';
  var date = new Date(centis * 10);
  var millis = date.getUTCMilliseconds();
  var sep = ':';
  var baseStr = pad2(date.getUTCMinutes()) + sep + pad2(date.getUTCSeconds());
  if (centis >= 360000) {
    var hours = Math.floor(centis / 360000);
    return hours + sep + baseStr;
  }
  var tenthsStr = Math.floor(millis / 100).toString();
  return [
    baseStr,
    m('tenths', '.' + tenthsStr)
  ];
}

function pad2(num) {
  return (num < 10 ? '0' : '') + num;
}
{'fraction_non_alphanumeric': 0.16045945005221024, 'fraction_numerical': 0.018447615732683605, 'mean_word_length': 3.726973684210526, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '324311', 'n_tokens_mistral': 1053, 'n_tokens_neox': 1005, 'n_words': 238}