'use strict';

var dayjs = require('dayjs');
var relativeTime = require('dayjs/plugin/relativeTime.js');
var timezone = require('dayjs/plugin/timezone.js');
var utc = require('dayjs/plugin/utc.js');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

var dayjs__default = /*#__PURE__*/_interopDefault(dayjs);
var relativeTime__default = /*#__PURE__*/_interopDefault(relativeTime);
var timezone__default = /*#__PURE__*/_interopDefault(timezone);
var utc__default = /*#__PURE__*/_interopDefault(utc);

dayjs__default.default.extend(utc__default.default);
dayjs__default.default.extend(relativeTime__default.default);
dayjs__default.default.extend(timezone__default.default);
var timeZone = dayjs__default.default.tz.guess();
dayjs__default.default.tz.setDefault(timeZone);
function formatDate(date, format = "DD/MM/YYYY") {
  return dayjs__default.default(date).format(format);
}
function formatDateToNow(date) {
  return dayjs__default.default(date).fromNow();
}
function parseUnix(time) {
  return dayjs__default.default.unix(time);
}
function getUnixTime(date) {
  return dayjs__default.default(date).unix();
}
function formatDateUnixTime(seconds, format = "DD/MM/YYYY") {
  return formatDate(dayjs__default.default.unix(seconds).toISOString(), format);
}
function diffDate(toDate, fromDate, config) {
  const formattedToDate = dayjs__default.default(toDate).format("YYYY-MM-DD");
  const formattedFromDate = dayjs__default.default(fromDate).format("YYYY-MM-DD");
  return dayjs__default.default(formattedFromDate).diff(dayjs__default.default(formattedToDate), config?.unit, config?.float);
}
function addNewDate(date, addDays = 0) {
  return dayjs__default.default(date).add(addDays, "day").toDate();
}

Object.defineProperty(exports, "dayjs", {
  enumerable: true,
  get: function () { return dayjs__default.default; }
});
exports.addNewDate = addNewDate;
exports.diffDate = diffDate;
exports.formatDate = formatDate;
exports.formatDateToNow = formatDateToNow;
exports.formatDateUnixTime = formatDateUnixTime;
exports.getUnixTime = getUnixTime;
exports.parseUnix = parseUnix;
