2018-06-19 18:48:14 -04:00
|
|
|
'use strict';
|
|
|
|
|
2018-07-18 02:55:09 -04:00
|
|
|
const _ = require('underscore');
|
|
|
|
const Mn = require('backbone.marionette');
|
|
|
|
const moment = require('moment');
|
|
|
|
const i18n = require('../app/i18n');
|
2018-06-19 18:48:14 -04:00
|
|
|
|
|
|
|
let render = Mn.Renderer.render;
|
|
|
|
|
|
|
|
Mn.Renderer.render = function (template, data, view) {
|
|
|
|
|
|
|
|
data = _.clone(data);
|
|
|
|
|
2018-07-18 00:28:41 -04:00
|
|
|
data.i18n = i18n;
|
|
|
|
|
2018-06-19 18:48:14 -04:00
|
|
|
/**
|
|
|
|
* @param {String} date
|
2018-08-01 07:18:17 -04:00
|
|
|
* @param {String} format
|
2018-06-19 18:48:14 -04:00
|
|
|
* @returns {String}
|
|
|
|
*/
|
2018-06-25 02:56:13 -04:00
|
|
|
data.formatDbDate = function (date, format) {
|
2018-06-19 18:48:14 -04:00
|
|
|
if (typeof date === 'number') {
|
2018-06-25 02:56:13 -04:00
|
|
|
return moment.unix(date).format(format);
|
2018-06-19 18:48:14 -04:00
|
|
|
}
|
|
|
|
|
2018-06-25 02:56:13 -04:00
|
|
|
return moment(date).format(format);
|
2018-06-19 18:48:14 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
return render.call(this, template, data, view);
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = Mn;
|