1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-25 17:40:29 +00:00

Deal with viewing date fields that don't exist

This commit is contained in:
Jeremy Ruston 2013-10-14 12:59:39 +01:00
parent cc4940f41f
commit ea0b298b78

View File

@ -80,7 +80,11 @@ ViewWidget.prototype.getValueAsText = function() {
// Calling getTiddlerText() triggers lazy loading of skinny tiddlers // Calling getTiddlerText() triggers lazy loading of skinny tiddlers
text = this.wiki.getTiddlerText(this.viewTitle); text = this.wiki.getTiddlerText(this.viewTitle);
} else { } else {
if($tw.utils.hop(tiddler.fields,this.viewField)) {
text = tiddler.fields[this.viewField]; text = tiddler.fields[this.viewField];
} else {
text = "";
}
} }
} else { // Use a special value if the tiddler is missing } else { // Use a special value if the tiddler is missing
switch(this.viewField) { switch(this.viewField) {
@ -112,8 +116,12 @@ ViewWidget.prototype.getValueAsDate = function(format) {
}; };
ViewWidget.prototype.getValueAsRelativeDate = function(format) { ViewWidget.prototype.getValueAsRelativeDate = function(format) {
var d = new Date(this.getValueAsText()); var value = this.getValueAsText();
return $tw.utils.getRelativeDate((new Date()) - d).description; if(value) {
return $tw.utils.getRelativeDate((new Date()) - (new Date(value))).description;
} else {
return "";
}
}; };
/* /*