package.cjs.utils.datetime.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of neeto-commons-frontend Show documentation
Show all versions of neeto-commons-frontend Show documentation
A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.
"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 = exports.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"));
}
};
var dateFormat = exports.dateFormat = timeFormat;
//# sourceMappingURL=datetime.js.map