import { m as moment } from './moment-bc12cb97.js';
import './_commonjsHelpers-0c4b6f40.js';

var timeDifferenceCalc = function timeDifferenceCalc(articlePublishedDate) {
  var dateNow = new Date();
  var articleDate = new Date(articlePublishedDate);

  var diffInMilliSeconds = Math.abs(articleDate - dateNow) / 1000;

  // calculate days
  var days = Math.floor(diffInMilliSeconds / 86400);
  diffInMilliSeconds -= days * 86400;

  // calculate hours
  var hours = Math.floor(diffInMilliSeconds / 3600) % 24;
  diffInMilliSeconds -= hours * 3600;

  // calculate minutes
  var minutes = Math.floor(diffInMilliSeconds / 60) % 60;
  diffInMilliSeconds -= minutes * 60;

  var difference = '';

  if (days == 0 && hours > 0) {
    difference = hours === 0 || hours === 1 ? hours + ' hour ago ' : hours + ' hours ago';
  }
  if (days == 0 && hours == 0 && minutes > 0) {
    difference = minutes === 0 || hours === 1 ? minutes + ' minute ago' : minutes + ' minutes ago';
  }
  if (days > 0) {
    difference = moment(articlePublishedDate).format('MMMM DD, YYYY');
  }

  return difference;
};

export { timeDifferenceCalc as default };
