<commit_before>import Ember from "ember";

export default Ember.Handlebars.makeBoundHelper(function(value) {
  var _MS_PER_DAY = 1000 * 60 * 60 * 24;
  var message_date = Date.parse(value);
  var current_time = Date.now();

  var day_difference = Math.floor((current_time - message_date) / _MS_PER_DAY);

  if(!message_date) {
    return "";
  } else if(day_difference < 1) {
    var time = moment(message_date).format('HH:mm');
    return Ember.I18n.t("day.today");
  } else if(day_difference < 7) {
    return moment(message_date).format('dddd');
  } else {
    return moment(message_date).format('DD MMM, YYYY');
  }
});
<commit_msg>GCW-415 - ensure times of messages are shown in the correct day boundary (today/yesterday)<commit_after>import Ember from "ember";

export default Ember.Handlebars.makeBoundHelper(function(value) {
  var _MS_PER_DAY = 1000 * 60 * 60 * 24;
  var message_date = Date.parse(value);
  var current_time = Date.now();

  var day_difference = (current_time - message_date) / _MS_PER_DAY;

  if(!message_date) {
    return "";
  } else if(day_difference < 1) {
    var time = moment(message_date).format('HH:mm');
    return Ember.I18n.t("day.today");
  } else if(day_difference < 7) {
    return moment(message_date).format('dddd');
  } else {
    return moment(message_date).format('DD MMM, YYYY');
  }
});

{'fraction_non_alphanumeric': 0.14210919970082272, 'fraction_numerical': 0.02318623784592371, 'mean_word_length': 4.186046511627907, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '5432660', 'n_tokens_mistral': 499, 'n_tokens_neox': 456, 'n_words': 100}