Authored by 陈峰

rss新增gmt的时间格式输出

... ... @@ -50,7 +50,7 @@ const index = (req, res, next) => {
return res.send(feed.render('rss-2.0'))
});
};
const rss = (req, res, next) => {
const rss = (req, res, next, gmt = '') => {
let gender = req.query.gender || '1,2,3',
items = [];
res.setHeader('Content-Type', 'text/xml; charset=utf-8');
... ... @@ -60,8 +60,10 @@ const rss = (req, res, next) => {
}
_.forEach(result, item => {
item.url = item.url.indexOf('http') >= 0 ? item.url : 'http://'+item.url;
item.publishTime = moment(new Date(item.publishTimeLong && parseFloat(item.publishTimeLong) || moment(item.publishTime, "MM月DD日 HH:mm"))).format('YYYY-MM-DD hh:mm:ss +0800')
let time = new Date(item.publishTimeLong && parseFloat(item.publishTimeLong) || moment(item.publishTime, "MM月DD日 HH:mm"));
console.log(gmt)
let format = gmt ? time : moment(time).format('YYYY-MM-DD hh:mm:ss +0800');
item.publishTime = format;
});
return res.render('rss/index', {
layout: false,
... ...
... ... @@ -55,6 +55,7 @@ router.get('/plustar/brandinfo', plustar.getDetailData); // 祕
router.post('/plustar/brandinfoAsync', plustar.getDetailDataAsync); // 国际优选详情页异步数据
router.get('/rss/new', rss.rss); // 订阅资讯
router.get('/rss/new-gmt', (req, res, next) => rss.rss(req, res, next, 'gmt')); // 订阅资讯
router.get(/^\/rss(\/\w+)?(\/\w+)?/, rss.index); // 订阅资讯
router.get('/info/listData', index.listDynamicData);
... ...
... ... @@ -17,7 +17,7 @@
<link><![CDATA[{{{url}}}&ref=rss]]></link>
<description><![CDATA[{{{intro}}}]]></description>
<pubDate><![CDATA[{{publishTime}}]]></pubDate>
<source><![CDATA[有货逛]]></source>
<source url="{{{url}}}&ref=rss"><![CDATA[有货逛]]></source>
<author>有货</author>
</item>
{{/items}}
... ...