more like this

exports.run = function(target_date) {
 
    // find the amount of seconds between now and target date
    var end_date = new Date(target_date).getTime();
    var current_date = new Date().getTime();
    var seconds_left = (end_date - current_date) / 1000;
 
    // calculate days left, based on 86,400 seconds per day
    var DaysToDate = parseInt(seconds_left / 86400);
return DaysToDate;
};

})();

all the best 

BJ

On Saturday, January 2, 2016 at 1:51:06 AM UTC, Hegart Dmishiv wrote:
>
> Okay, I've made an attempt 
> <https://hegart-dmishiv.github.io/my-TW5-dev-instance/#%24%3A%2F_Macros%2FDaysToDate.js>
>  
> at doing this myself. With my serious lack of programming skills, I've 
> cobbled together something from the TiddlyWiki core module 
> $:/core/modules/macros/now.js 
> <http://tiddlywiki.com/#%24%3A%2Fcore%2Fmodules%2Fmacros%2Fnow.js> and 
> the tutorial 
> <https://blog.grade.net/how-to-create-a-simple-javascript-countdown-timer> 
> I was looking at earlier. I didn't need the hours, minutes and seconds 
> information, so I dropped all that guff. For now I went with only making a 
> single call to the macro on loading a tiddler, rather than trying to make 
> it dynamically updating at the top of the wiki instance as a MOTD. It 
> seemed simpler to just at least display the number of days, once, 
> statically.
>
> However, I'm getting a big red Internal Javascript Error dialog box, which 
> says "ReferenceError: assignment to undeclared variable DaysToDate". 
> Could some kind Javascript guru take a look at my first teetering steps and 
> let me know where I went wrong please?
>
> Also, I have no idea of the format to use when calling the macro. What I'm 
> trying presently is *<<DaysToDate dd/mm/yyyy>>* but I'm not sure what 
> date format it will take. Of course, the preexisting Internal Javascript 
> error hampers my efforts so far to quantify this. ;-)
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/b8186134-2fc5-459f-b25d-755215470b5e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to