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

25 lines
568 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 = {};
}
2014-10-25 00:59:06 +02:00
var times = options.hash.times ? options.hash.times : false,
format = options.hash.format ? options.hash.format : 'LLLL';
if (times === true) {
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
}
}