1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-24 00:50:28 +00:00

Fix relative date viewer so that it displays absolute dates in static HTML representations

This commit is contained in:
Jeremy Ruston 2013-03-19 19:06:23 +00:00
parent ec83bc5c64
commit 2aff4db744

View File

@ -20,9 +20,10 @@ var RelativeDateViewer = function(viewWidget,tiddler,field,value) {
};
RelativeDateViewer.prototype.render = function() {
this.relativeDate = undefined;
var template = this.viewWidget.renderer.getAttribute("template","DD MMM YYYY"),
value = "";
if(this.value !== undefined) {
this.relativeDate = $tw.utils.getRelativeDate((new Date()) - this.value);
value = $tw.utils.formatDateString(this.value,template);
}
// Set the element details
this.viewWidget.tag = "span";
@ -31,7 +32,7 @@ RelativeDateViewer.prototype.render = function() {
};
this.viewWidget.children = this.viewWidget.renderer.renderTree.createRenderers(this.viewWidget.renderer.renderContext,[{
type: "text",
text: this.relativeDate ? this.relativeDate.description : ""
text: value
}]);
};
@ -39,9 +40,7 @@ RelativeDateViewer.prototype.render = function() {
Trigger the timer when the relative date is put into the DOM
*/
RelativeDateViewer.prototype.postRenderInDom = function() {
if(this.relativeDate) {
this.update();
}
this.update();
};
/*