Repository URL to install this package:
|
Version:
1.2.1 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.toPrettyDate = toPrettyDate;
exports.default = void 0;
var _index = require("../chain-able/index.js");
var _exotic = require("../exotic");
var _dateFns = require("date-fns");
const DATE_FORMAT = 'YYYY-MM-DD h:mm A';
const DATE_ISO_FORMAT = 'YYYY-MM-DD hh:mm:ss a ZZ';
const toDateFormat = (0, _index.curry)(2, (formatOption, date) => (0, _dateFns.format)(date, formatOption));
const toLongDate = toDateFormat(DATE_FORMAT);
const toISODate = toDateFormat(DATE_ISO_FORMAT);
const toTimeAgoInWords = date => (0, _dateFns.distanceInWordsToNow)(date); // @todo - this isn't proper for parsing the data given by apis
// may need getActualDate
function toPrettyDate(date) {
date = (0, _exotic.toDate)(date);
if ((0, _dateFns.isThisWeek)(date)) {
return toTimeAgoInWords(date);
} else {
return toLongDate(date);
}
}
var _default = toPrettyDate;
exports.default = _default;