<commit_before>import { helper } from '@ember/component/helper';
import { assert } from '@ember/debug';
import { formatDuration, intervalToDuration } from 'date-fns';

export function duration([time], { removeZero = false }) {
  // intervalToDuration creates a durationObject that turns the seconds (ex 3600) to respective:
  // { years: 0, months: 0, days: 0, hours: 1, minutes: 0, seconds: 0 }
  // then formatDuration returns the filled in keys of the durationObject

  if (removeZero && time === '0') {
    return null;
  }

  // time must be in seconds
  let duration = Number.parseInt(time, 10);
  assert('could not parse time', !isNaN(duration));
  return formatDuration(intervalToDuration({ start: 0, end: duration * 1000 }));
}

export default helper(duration);<commit_msg>Return the input from format-duration helper when it can't be parsed as an int. (#14118)<commit_after>import { helper } from '@ember/component/helper';
import { formatDuration, intervalToDuration } from 'date-fns';

export function duration([time], { removeZero = false }) {
  // intervalToDuration creates a durationObject that turns the seconds (ex 3600) to respective:
  // { years: 0, months: 0, days: 0, hours: 1, minutes: 0, seconds: 0 }
  // then formatDuration returns the filled in keys of the durationObject

  if (removeZero && time === '0') {
    return null;
  }

  // time must be in seconds
  let duration = Number.parseInt(time, 10);
  if (isNaN(duration)) {
    return time;
  }
  return formatDuration(intervalToDuration({ start: 0, end: duration * 1000 }));
}

export default helper(duration);
{'fraction_non_alphanumeric': 0.12358845671267252, 'fraction_numerical': 0.025721455457967377, 'mean_word_length': 4.229508196721311, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5608965', 'n_tokens_mistral': 485, 'n_tokens_neox': 446, 'n_words': 172}