mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-25 01:20:30 +00:00
Deal with viewing date fields that don't exist
This commit is contained in:
parent
cc4940f41f
commit
ea0b298b78
@ -80,7 +80,11 @@ ViewWidget.prototype.getValueAsText = function() {
|
||||
// Calling getTiddlerText() triggers lazy loading of skinny tiddlers
|
||||
text = this.wiki.getTiddlerText(this.viewTitle);
|
||||
} else {
|
||||
text = tiddler.fields[this.viewField];
|
||||
if($tw.utils.hop(tiddler.fields,this.viewField)) {
|
||||
text = tiddler.fields[this.viewField];
|
||||
} else {
|
||||
text = "";
|
||||
}
|
||||
}
|
||||
} else { // Use a special value if the tiddler is missing
|
||||
switch(this.viewField) {
|
||||
@ -112,8 +116,12 @@ ViewWidget.prototype.getValueAsDate = function(format) {
|
||||
};
|
||||
|
||||
ViewWidget.prototype.getValueAsRelativeDate = function(format) {
|
||||
var d = new Date(this.getValueAsText());
|
||||
return $tw.utils.getRelativeDate((new Date()) - d).description;
|
||||
var value = this.getValueAsText();
|
||||
if(value) {
|
||||
return $tw.utils.getRelativeDate((new Date()) - (new Date(value))).description;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user