import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
var Time = /*#__PURE__*/function () {
  function Time() {
    _classCallCheck(this, Time);
  }
  return _createClass(Time, null, [{
    key: "getTimeFromSeconds",
    value: function getTimeFromSeconds(secs) {
      var totalSeconds = Math.ceil(secs);
      var days = Math.floor(totalSeconds / (60 * 60 * 24));
      var hours = Math.floor(totalSeconds % (60 * 60 * 24) / (60 * 60));
      var minutes = Math.floor(totalSeconds % (60 * 60) / 60);
      var seconds = Math.floor(totalSeconds % 60);
      return {
        totalSeconds: totalSeconds,
        seconds: seconds,
        minutes: minutes,
        hours: hours,
        days: days
      };
    }
  }, {
    key: "getSecondsFromExpiry",
    value: function getSecondsFromExpiry(expiry, shouldRound) {
      var now = new Date().getTime();
      var milliSecondsDistance = expiry - now;
      if (milliSecondsDistance > 0) {
        var val = milliSecondsDistance / 1000;
        return shouldRound ? Math.round(val) : val;
      }
      return 0;
    }
  }, {
    key: "getSecondsFromPrevTime",
    value: function getSecondsFromPrevTime(prevTime, shouldRound) {
      var now = new Date().getTime();
      var milliSecondsDistance = now - prevTime;
      if (milliSecondsDistance > 0) {
        var val = milliSecondsDistance / 1000;
        return shouldRound ? Math.round(val) : val;
      }
      return 0;
    }
  }, {
    key: "getSecondsFromTimeNow",
    value: function getSecondsFromTimeNow() {
      var now = new Date();
      var currentTimestamp = now.getTime();
      var offset = now.getTimezoneOffset() * 60;
      return currentTimestamp / 1000 - offset;
    }
  }, {
    key: "getFormattedTimeFromSeconds",
    value: function getFormattedTimeFromSeconds(totalSeconds, format) {
      var _Time$getTimeFromSeco = Time.getTimeFromSeconds(totalSeconds),
        secondsValue = _Time$getTimeFromSeco.seconds,
        minutes = _Time$getTimeFromSeco.minutes,
        hours = _Time$getTimeFromSeco.hours;
      var ampm = '';
      var hoursValue = hours;
      if (format === '12-hour') {
        ampm = hours >= 12 ? 'pm' : 'am';
        hoursValue = hours % 12;
      }
      return {
        seconds: secondsValue,
        minutes: minutes,
        hours: hoursValue,
        ampm: ampm
      };
    }
  }]);
}();
export { Time as default };