[tw] Re: [TWC] DatePlugin question
On Tuesday, June 23, 2015 at 8:00:35 AM UTC-7, jpt wrote: Using a suggestion that was made in this group I am able to display a tiddler titled with a specific date (20150623 for example) by writing this: tiddler {{(newDate()).formatString ('0MM0DD')}} However I can not figure out how to format it so it displays a tiddler with a date other than today, e.g. tomorrow's date. I also tried the DatePlugin and wrote this: tiddler {{showDate(Y M D+1 0MM0DD}} but it gives me an error message. What am I doing wrong? I'll answer the second part first: * In TWC, macros don't generate text output. They generate and render DOM elements. Thus, you cannot use the output of a macro as a parameter of another macro. * In TW5, macros are used to assemble text output and the returned value can, with syntax limitations, be used as a parameter of another macro. Now on to the real tech: new Date() returns the current date/time in milliseconds since midnight on Jan. 1, 1970 (the start of time, computationally speaking!). As you've learned, this value can then be formatted using .formatString ('0MM0DD'). To use a date other than the current one, pass the number of milliseconds into the Date() function. For example, if you use new Date(0).formatString(...), you will see 19700101. (note: the date is adjusted for your local time zone, so if you are west of UDT, the start date will show as 19691231) You can calculate a new value from the current date/time value by adding/subtracting the appropriate number of milliseconds. For example, one day is 8640 milliseconds (60 x 60 x 24 x 1000). Thus, to get tomorrow's date, you would use new Date() + 8640 as the input param, like this: new Date(new Date() + 8640).formatString('0MM0DD 0hh:0mm:0ss'); enjoy, -e Eric Shulman ELS Design Studios TiddlyTools - Small Tools for Big Ideas! InsideTiddlyWiki: The Missing Manuals YOUR DONATIONS ARE VERY IMPORTANT! HELP ME TO HELP YOU - MAKE A CONTRIBUTION TO MY TIP JAR... http://TiddlyTools.github.com/fundraising.html#MakeADonation Professional TiddlyWiki Consulting Services... Analysis, Design, and Custom Solutions: http://www.TiddlyTools.com/#Contact -- 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 tiddlywiki+unsubscr...@googlegroups.com. To post to this group, send email to tiddlywiki@googlegroups.com. Visit this group at http://groups.google.com/group/tiddlywiki. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/7e4e99b9-354c-4ce8-b363-d9de34cea074%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[tw] Re: [TWC] DatePlugin question
Thank you. I understand now that in TWC macros generate and render DOM elements and cannot be used as parameters for other macros. For whatever reason I still have trouble with the code. When I write tiddler {{(new Date(new Date() + 8640).formatString('0MM0DD')}} it gives me Error in macro tiddler. To try to see if I missed something I used the WriteIt Plugin and all of the following lines display correctly: writeIt {{(new Date()).formatString('0MM0DD') gives 20150623 (today's date); writeIt {{(new Date(0)).formatString('0MM0DD') gives 19691231 (as mentioned in the answer); writeIt {{(new Date(0 + 8640)).formatString('0MM0DD') gives 19700101. However when I write: writeIt {{(new Date(new Date() + 8640)).formatString('0MM0DD') I get *NaNNaNNaN*. What did I miss? Regards, Johannes On Tuesday, June 23, 2015 at 11:00:35 AM UTC-4, jpt wrote: Hello, Using a suggestion that was made in this group I am able to display a tiddler titled with a specific date (20150623 for example) by writing this: tiddler {{(newDate()).formatString ('0MM0DD')}} However I can not figure out how to format it so it displays a tiddler with a date other than today, e.g. tomorrow's date. I also tried the DatePlugin and wrote this: tiddler {{showDate(Y M D+1 0MM0DD}} but it gives me an error message. What am I doing wrong? Best, Johannes -- 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 tiddlywiki+unsubscr...@googlegroups.com. To post to this group, send email to tiddlywiki@googlegroups.com. Visit this group at http://groups.google.com/group/tiddlywiki. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/5c7c4350-70d9-4e6c-99ca-9782a0e8c102%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[tw] Re: [TWC] DatePlugin question
On Tuesday, June 23, 2015 at 10:32:54 AM UTC-7, jpt wrote: For whatever reason I still have trouble with the code. When I write tiddler {{(new Date(new Date() + 8640).formatString('0MM0DD')}} it gives me Error in macro tiddler. What did I miss? You have an extra open parentheses, just before the first new. Note also, when you see the red error in macro, if you click on the message, it shows more details. -e -- 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 tiddlywiki+unsubscr...@googlegroups.com. To post to this group, send email to tiddlywiki@googlegroups.com. Visit this group at http://groups.google.com/group/tiddlywiki. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/006da328-5e9c-42e9-8f0a-2ff74fc5321a%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[tw] Re: [TWC] DatePlugin question
Dear Mr Shulman, Thank you very much! It got me in the right direction. Still was not able to get tomorrow's tiddler displayed no matter that the error message disappeared. Until I read somewhere to put a + in front of the second new Date. Like so: tiddler {{new Date(+ new Date() + 8640).formatString('0MM0DD')}} Seems that this new Date was interpreted as something other than a number (which would explain the NaN output). Can that be or is something else wrong and the + handling it is just a fluke? It now works perfectly and I can add and subtract days as I please. Thank you very much. Johannes On Tuesday, June 23, 2015 at 11:00:35 AM UTC-4, jpt wrote: Hello, Using a suggestion that was made in this group I am able to display a tiddler titled with a specific date (20150623 for example) by writing this: tiddler {{(newDate()).formatString ('0MM0DD')}} However I can not figure out how to format it so it displays a tiddler with a date other than today, e.g. tomorrow's date. I also tried the DatePlugin and wrote this: tiddler {{showDate(Y M D+1 0MM0DD}} but it gives me an error message. What am I doing wrong? Best, Johannes -- 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 tiddlywiki+unsubscr...@googlegroups.com. To post to this group, send email to tiddlywiki@googlegroups.com. Visit this group at http://groups.google.com/group/tiddlywiki. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/83f19212-c92d-4bd8-9961-40459ee0821d%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.