@seidhr/sanity-plugin-muna-schemas
Version:
Muna or ᛗᚢᚾᚨ means remember in norse. Muna is a schema for the Sanity Studio that enables detailed descriptions of cultural heritage objects and knowledge about their contexts as well as pages about them (or anything else really.)
36 lines (26 loc) • 1.02 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.timespanAsString = void 0;
var dayjs = require('dayjs');
var _ = require('lodash');
var localizedFormat = require('dayjs/plugin/localizedFormat');
dayjs.extend(localizedFormat);
require('dayjs/locale/nb'); // eslint-disable-next-line max-params
var timespanAsString = (bb, eb, date, be, ee, lang) => {
var dates = _.pickBy({
bb,
eb,
date,
be,
ee
}, _.identity);
dates = Object.assign({}, ...Object.keys(dates).map(d => ({
[d]: dayjs(dates[d]).locale(lang).format('LL')
})));
var prettyTimespan = "".concat(dates.date || '').concat(dates.bb || '').concat(dates.bb && dates.eb ? '~' : '').concat(dates.eb || '') + "".concat((dates.bb || dates.eb) && (dates.be || dates.ee) ? ' / ' : '') + "".concat(dates.be || '').concat(dates.be && dates.ee ? '~' : '').concat(dates.ee || '');
return prettyTimespan;
};
exports.timespanAsString = timespanAsString;
//# sourceMappingURL=timespanAsString.js.map