All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.cjs.utils.datetime.js Maven / Gradle / Ivy

Go to download

A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.

There is a newer version: 4.12.3
Show newest version
"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.timeFormat = exports.dateFormat = void 0;
var _dayjs = _interopRequireDefault(require("./dayjs"));
/* eslint-disable @bigbinary/neeto/use-standard-date-time-formats */

var getDefaultFormat = function getDefaultFormat() {
  var _globalProps$user$dat, _globalProps, _globalProps$user;
  return (_globalProps$user$dat = (_globalProps = globalProps) === null || _globalProps === void 0 ? void 0 : (_globalProps$user = _globalProps.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.dateFormat) !== null && _globalProps$user$dat !== void 0 ? _globalProps$user$dat : "DD/MM/YYYY";
};
var timeFormat = {
  fromNow: function fromNow(time) {
    return (0, _dayjs["default"])(time).fromNow();
  },
  time: function time(_time) {
    return (0, _dayjs["default"])(_time).format("LT");
  },
  timeWithSeconds: function timeWithSeconds(time) {
    return (0, _dayjs["default"])(time).format("LTS");
  },
  date: function date(time) {
    return (0, _dayjs["default"])(time).format("ll");
  },
  dateWeek: function dateWeek(time) {
    return (0, _dayjs["default"])(time).format("ll ddd");
  },
  dateWeekDayExtended: function dateWeekDayExtended(time) {
    return (0, _dayjs["default"])(time).format("ll dddd");
  },
  dateWeekWithoutYear: function dateWeekWithoutYear(time) {
    return (0, _dayjs["default"])(time).format("MMM D, ddd");
  },
  dateWeekWithoutYearDayExtended: function dateWeekWithoutYearDayExtended(time) {
    return (0, _dayjs["default"])(time).format("MMM D, dddd");
  },
  dateTime: function dateTime(time) {
    return (0, _dayjs["default"])(time).format("ll LT");
  },
  dateTimeWithSeconds: function dateTimeWithSeconds(time) {
    return (0, _dayjs["default"])(time).format("ll LTS");
  },
  dateWeekTime: function dateWeekTime(time) {
    return (0, _dayjs["default"])(time).format("ll ddd LT");
  },
  dateWeekTimeDayExtended: function dateWeekTimeDayExtended(time) {
    return (0, _dayjs["default"])(time).format("ll dddd LT");
  },
  extended: function extended(time) {
    var dateTime = (0, _dayjs["default"])(time).format("dddd LL LT");
    var fromNow = (0, _dayjs["default"])(time).fromNow();
    return "".concat(dateTime, " (").concat(fromNow, ")");
  },
  "default": function _default(time) {
    return (0, _dayjs["default"])(time).format(getDefaultFormat());
  },
  defaultWithTime: function defaultWithTime(time) {
    return (0, _dayjs["default"])(time).format("".concat(getDefaultFormat(), " LTS"));
  }
};
exports.timeFormat = timeFormat;
var dateFormat = timeFormat;
exports.dateFormat = dateFormat;
//# sourceMappingURL=datetime.js.map




© 2015 - 2024 Weber Informatics LLC | Privacy Policy