$:/state/list-dates/date1 and $:/state/list-dates/date2 are transcluded. But instead of transclusion, I want to use $view widget on the text with parameters such as format and template set appropriately.
How do I do that? I tried my hand at it. But got syntax error.
In place of {$:/state/list-dates/date1}, I want to use the output of <$view tiddler=" $:/state/list-dates/date1" format="date" template="YYYY-0MM-0DD ddd" />
Ah, I think I see the problem, since the second format:date[] comes after the addsuffix, it’s trying to convert the whole of what’s been generated as a date, including your - separator etc.
Here’s my best guess as to what you’re looking for:
Is there a way to assign the value of $view widget to a variable and including the value of that variable instead of transclusion? That would make life simpler.
Assuming that $:/state/list-date/date1 and $:/state/list-date/date2 each contain a standard TW date value (i.e., using 17-digit zero-padded datetime format, YYYYMMDDhhmmssXXX, then the filter syntax
and the syntax suggested by @stobot should produce the output you want.
One detail: the TWCore formatting assumes that the input is a UTC datetime value (with a timezone offset of “+00:00”), but both the format:date[...] filter syntax and the <$view ... format="date" ...> syntax produce output for the local timezone (i.e., adjusting the result by the timezone offset for your locale). To prevent this timezone offset from being applied, the template used for formatting the output needs to include [UTC] at the beginning (i.e., [UTC]YYYY-0MM-0DD ddd).
However, this presents a minor problem, because you can’t use literal square brackets within the format:date[...] filter syntax, since the syntax itself uses square brackets to surround the “datetime template” parameter value. Fortunately, there is a workaround by defining the template value as a variable that includes the [UTC] syntax, and then referencing that variable in the filter syntax.
Thus, to achieve the proper result, you could use wikitext code like this:
The first part of the filter, [<tid>get[text]addsuffix<lbr>], gets the current tiddler content and, if not blank, adds a linebreak.
The next three parts of the filter, [{test/list-dates/date1}format:date<template>] [[ - ]] [{test/list-dates/date2}format:date<template>] formats each input date using the desired template, with a literal " - " in-between.
The last part of the filter joins the previous parts together to produce the desired output.