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
[{$:/state/list-date/date1}format:date[YYYY-0MM-0DD ddd]]
is equivalent to
<$view tiddler="$:/state/list-date/date1" field="text" format="date" template="YYYY-0MM-0DD ddd"
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:
<$vars tid="test" template="[UTC]YYYY-0MM-0DD ddd" lbr="
">
<$button> click me!
<$action-setfield $tiddler="test" text={{{ [<tid>get[text]addsuffix<lbr>] [{test/list-dates/date1}format:date<template>] [[ - ]] [{test/list-dates/date2}format:date<template>] +[join[]] }}} />
</$button>
Notes:
-
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.
That should do it. Let me know how it goes…
enjoy,
-e