Once again Jed's right and I should have known better: I can't get the
datepicker widget to spit out the date into 3 fields, so now I'm editing
Jed's code:
Here's what I think should work but doesn't:
/*\
title: $:/inmysocks/macros/day-diff2.js
type: application/javascript
module-type: macro
Takes two dates and returns their difference in days
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
/*
Information about this macro
*/
exports.name = "day-diff2";
exports.params = [
{name: "mydate1"},
{name: "mydate2"}
];
/*
Run the macro
*/
exports.run = function(mydate1, mydate2) {
//Make each date object.
var date1 = new Date(mydate1);
var date2 = new Date(mydate2);
//Find difference in milliseconds.
var elapsed = date2.getTime()-date1.getTime();
//Number of milliseconds in a day.
var dayMS = 86400000;
//Convert milliseconds to year months and days
var days_diff = Math.floor(elapsed/dayMS);
var result = days_diff;
return result;
};
})();
When I write bash scripts my first attempts are always wrong, and then I
test things line by line at the terminal to look at the errors and
eventually can get it to work.
How do you do that in this case? Is there such a thing as a "javascript
terminal" I can test things with?
Merci!
- Dave
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/552b9ef0-9a54-417d-a034-050477650f43%40googlegroups.com.