<commit_before>/* -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */

'use strict';

(function(exports) {
  var SERVER_URL = Config.server_url;
  var TIMEOUT = Config.request_timeout;

  //change default path for gaia-component-utils
  window.packagesBaseUrl = 'libs/components/';

  function _beautify(value) {
    if (value < 10) {
      return '0' + value;
    } else {
      return value;
    }
  }

  var Utils = {
    date: {
      shared: new Date(),
      get format() {
        // Remove the accessor
        delete Utils.date.format;
        // Late initialization allows us to safely mock the mozL10n object
        // without creating race conditions or hard script dependencies
        return (Utils.date.format = new navigator.mozL10n.DateTimeFormat());
      }
    },
    getFormattedHour: function ut_getFormattedHour(time) {
      this.date.shared.setTime(+time);
      return this.date.format.localeFormat(
        this.date.shared, navigator.mozL10n.get('shortTimeFormat')
      );
    },
    getDayDate: function ut_getDayDate(time) {
      this.date.shared.setTime(+time);
      this.date.shared.setHours(0, 0, 0, 0);
      return this.date.shared.getTime();
    },
    getDurationPretty: function ut_getDurationPretty(time) {
      var minutes = _beautify(Math.floor(time/60));
      var seconds = _beautify(Math.floor(time%60));
      return minutes + ':' + seconds + ' min';
    },
    getRevokeDate: function ut_getDurationPretty(time, serverTime) {
      var diff = 0, currentMs = 0;

      currentMs = serverTime ? serverTime : ((new Date()).getTime());
      diff = time - currentMs;

      var args = {
        value: 0
      };

      if (diff > 0) {
        args.value = Math.round(diff/86400000);
      }
      return navigator.mozL10n.get('daysLeft', args);<commit_msg>Bug 1127272 - [Loop] Rooms will appear as expired when half of the day they should expire is over<commit_after>/* -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */

'use strict';

(function(exports) {
  var SERVER_URL = Config.server_url;
  var TIMEOUT = Config.request_timeout;

  //change default path for gaia-component-utils
  window.packagesBaseUrl = 'libs/components/';

  function _beautify(value) {
    if (value < 10) {
      return '0' + value;
    } else {
      return value;
    }
  }

  var Utils = {
    date: {
      shared: new Date(),
      get format() {
        // Remove the accessor
        delete Utils.date.format;
        // Late initialization allows us to safely mock the mozL10n object
        // without creating race conditions or hard script dependencies
        return (Utils.date.format = new navigator.mozL10n.DateTimeFormat());
      }
    },
    getFormattedHour: function ut_getFormattedHour(time) {
      this.date.shared.setTime(+time);
      return this.date.format.localeFormat(
        this.date.shared, navigator.mozL10n.get('shortTimeFormat')
      );
    },
    getDayDate: function ut_getDayDate(time) {
      this.date.shared.setTime(+time);
      this.date.shared.setHours(0, 0, 0, 0);
      return this.date.shared.getTime();
    },
    getDurationPretty: function ut_getDurationPretty(time) {
      var minutes = _beautify(Math.floor(time/60));
      var seconds = _beautify(Math.floor(time%60));
      return minutes + ':' + seconds + ' min';
    },
    getRevokeDate: function ut_getDurationPretty(time, serverTime) {
      var diff = 0, currentMs = 0;

      currentMs = serverTime ? serverTime : ((new Date()).getTime());
      diff = time - currentMs;

      var args = {
        value: 0
      };

      if (diff > 0) {
        args.value = Math.ceil(diff/86400000);
      }
      return navigator.mozL10n.get('daysLeft', args);
{'fraction_non_alphanumeric': 0.1257423186160599, 'fraction_numerical': 0.020397624580428608, 'mean_word_length': 2.6409774436090228, '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': '6046942', 'n_tokens_mistral': 1288, 'n_tokens_neox': 1209, 'n_words': 292}