Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Shortened getDate & getUpdatedDate

  • Loading branch information...
commit 0ae7d26bf9e795c0bf1c372e6b24d8edb795de93 1 parent b033f96
@fb55 fb55 authored
Showing with 11 additions and 21 deletions.
  1. +11 −21 lib/nodepie.js
View
32 lib/nodepie.js
@@ -755,19 +755,15 @@ NodePie.Item.prototype.getTitle = function(){
* console.log("Created: " + date.getFullYear());
**/
NodePie.Item.prototype.getDate = function(){
- var dcns = this.feed.namespaces[NodePie.NS.DC], date;
+ var dcns = this.feed.namespaces[NodePie.NS.DC];
- date = this.element.pubDate || this.element.published || this.element.created || this.element.issued ||
- this.element.updated || this.element.modified || (dcns && this.element[dcns+":date"]);
-
- if(!date){
- return false;
- }
+ var date = new Date(
+ this.element.pubDate || this.element.published || this.element.created || this.element.issued ||
+ this.element.updated || this.element.modified || (dcns && this.element[dcns+":date"])
+ );
- date = new Date(date);
- if(!date.getFullYear()){
+ if(!date.getTime())
return false;
- }
if(date.getTime() > Date.now()){
return new Date();
@@ -788,22 +784,16 @@ NodePie.Item.prototype.getDate = function(){
* console.log("Updated: " + date.getFullYear());
**/
NodePie.Item.prototype.getUpdateDate = function(){
- var date = this.element.updated || this.element.modified;
-
- if(!date){
- // fallback to creation date
- return this.getDate();
- }
+ var date = new Date(
+ this.element.updated || this.element.modified
+ );
- date = new Date(date);
- if(!date.getFullYear()){
+ if(!date.getTime())
// fallback to creation date
return this.getDate();
- }
- if(date.getTime() > Date.now()){
+ if(date.getTime() > Date.now())
return new Date();
- }
return date;
};
Please sign in to comment.
Something went wrong with that request. Please try again.