decide.nolog.cz/app/helpers/formatted-date.js

24 lines
566 B
JavaScript
Raw Normal View History

2014-11-01 18:00:46 +01:00
/* global moment */
2014-10-30 21:44:22 +01:00
2014-10-25 00:59:06 +02:00
export default function(date, options) {
if (options === undefined) {
options = {};
}
if (options.hash === undefined) {
options.hash = {};
}
2016-01-29 11:24:43 +01:00
const times = options.hash.times ? options.hash.times : false;
const format = options.hash.format ? options.hash.format : 'LLLL';
2014-10-25 00:59:06 +02:00
if (times === true) {
2016-01-29 11:24:43 +01:00
return moment(date).format(format);
} else {
return moment(date).format(
2015-08-01 22:43:06 +02:00
moment.localeData().longDateFormat(format)
.replace(
moment.localeData().longDateFormat('LT'), '')
.trim()
);
2014-10-25 00:59:06 +02:00
}
}