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 ('YYYY0MM0DD')}}>>
> 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 "YYYY0MM0DD"}}>>
> 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
('YYYY0MM0DD').
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 86400000 milliseconds (60 x 60 x 24 x 1000). Thus, to get
tomorrow's date, you would use "new Date() + 86400000" as the input param,
like this:
new Date(new Date() + 86400000).formatString('YYYY0MM0DD 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 [email protected].
To post to this group, send email to [email protected].
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.