mirror of
https://github.com/thumbsup/thumbsup
synced 2024-11-15 18:12:46 +00:00
03a9c9a319
Every theme is made of { Handlebars + Less + Partials + Helpers + Public }
22 lines
466 B
JavaScript
22 lines
466 B
JavaScript
const moment = require('moment')
|
|
|
|
/*
|
|
Render a date in a legible format
|
|
Usage:
|
|
{{date taken}}
|
|
{{date taken "MMMM YYYY"}}
|
|
{{date taken "ago"}}
|
|
*/
|
|
module.exports = (date, format) => {
|
|
if (typeof format !== 'string') {
|
|
// default format
|
|
return moment(date).format('DD MMM YYYY')
|
|
} else if (format === 'ago') {
|
|
// some time ago
|
|
return moment(date).fromNow()
|
|
} else {
|
|
// custom format
|
|
return moment(date).format(format)
|
|
}
|
|
}
|