package.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.
/* eslint-disable @bigbinary/neeto/use-standard-date-time-formats */
import dayjs from "./dayjs";
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";
};
export var timeFormat = {
fromNow: function fromNow(time) {
return dayjs(time).fromNow();
},
time: function time(_time) {
return dayjs(_time).format("LT");
},
timeWithSeconds: function timeWithSeconds(time) {
return dayjs(time).format("LTS");
},
date: function date(time) {
return dayjs(time).format("ll");
},
dateWeek: function dateWeek(time) {
return dayjs(time).format("ll ddd");
},
dateWeekDayExtended: function dateWeekDayExtended(time) {
return dayjs(time).format("ll dddd");
},
dateWeekWithoutYear: function dateWeekWithoutYear(time) {
return dayjs(time).format("MMM D, ddd");
},
dateWeekWithoutYearDayExtended: function dateWeekWithoutYearDayExtended(time) {
return dayjs(time).format("MMM D, dddd");
},
dateTime: function dateTime(time) {
return dayjs(time).format("ll LT");
},
dateTimeWithSeconds: function dateTimeWithSeconds(time) {
return dayjs(time).format("ll LTS");
},
dateWeekTime: function dateWeekTime(time) {
return dayjs(time).format("ll ddd LT");
},
dateWeekTimeDayExtended: function dateWeekTimeDayExtended(time) {
return dayjs(time).format("ll dddd LT");
},
extended: function extended(time) {
var dateTime = dayjs(time).format("dddd LL LT");
var fromNow = dayjs(time).fromNow();
return "".concat(dateTime, " (").concat(fromNow, ")");
},
"default": function _default(time) {
return dayjs(time).format(getDefaultFormat());
},
defaultWithTime: function defaultWithTime(time) {
return dayjs(time).format("".concat(getDefaultFormat(), " LTS"));
}
};
export var dateFormat = timeFormat;
//# sourceMappingURL=datetime.js.map