diff --git a/lib/index.js b/lib/index.js index 2ad40a4..ef158bc 100755 --- a/lib/index.js +++ b/lib/index.js @@ -39,7 +39,9 @@ function generateXML (data){ channel.push({ image: [ {url: data.image_url}, {title: data.title}, {link: data.site_url} ] }); } channel.push({ generator: data.generator }); - channel.push({ lastBuildDate: new Date().toUTCString() }); + if (!data.omitBuildDate) { + channel.push({ lastBuildDate: new Date().toUTCString() }); + } ifTruePush(data.feed_url, channel, { 'atom:link': { _attr: { href: data.feed_url, rel: 'self', type: 'application/rss+xml' } } }); ifTruePush(data.author, channel, { 'author': { _cdata: data.author } }); @@ -159,6 +161,7 @@ function RSS (options, items) { this.custom_namespaces = options.custom_namespaces || {}; this.custom_elements = options.custom_elements || []; this.items = items || []; + this.omitBuildDate = options.omitBuildDate || false; this.item = function (options) { options = options || {}; diff --git a/test/expectedOutput/omitBuildDate.xml b/test/expectedOutput/omitBuildDate.xml new file mode 100644 index 0000000..592ac2b --- /dev/null +++ b/test/expectedOutput/omitBuildDate.xml @@ -0,0 +1,9 @@ + + + <![CDATA[title]]> + + http://example.com + RSS for Node + + + \ No newline at end of file diff --git a/test/index.js b/test/index.js index 7467c2c..8e9088d 100644 --- a/test/index.js +++ b/test/index.js @@ -336,3 +336,17 @@ test('custom namespaces', function(t) { t.equal(feed.xml({indent: true}), expectedOutput.customNamespaces); }); + +test('omit build date', function(t) { + t.plan(1); + + var feed = new RSS({ + title: 'title', + description: 'description', + feed_url: 'http://example.com/rss.xml', + site_url: 'http://example.com', + omitBuildDate: true + }); + + t.equal(feed.xml({indent: true}), expectedOutput.omitBuildDate); +}); \ No newline at end of file