0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-27 22:49:56 -05:00
ghost/core/client/utils/date-formatting.js

22 lines
673 B
JavaScript
Raw Normal View History

/* global moment */
var parseDateFormats = ["DD MMM YY HH:mm",
"DD MMM YYYY HH:mm",
"DD/MM/YY HH:mm",
"DD/MM/YYYY HH:mm",
"DD-MM-YY HH:mm",
"DD-MM-YYYY HH:mm",
"YYYY-MM-DD HH:mm"],
displayDateFormat = 'DD MMM YY @ HH:mm';
//Parses a string to a Moment
var parseDateString = function (value) {
return value ? moment(value, parseDateFormats) : '';
};
//Formats a Date or Moment
var formatDate = function (value) {
return value ? moment(value).format(displayDateFormat) : '';
};
export {parseDateString, formatDate};