I have finally decided to upgrade all of my TWs to v2.2, so I'm
currently composing a sample (or prefab?) with all the basic components.
In order to display the dates in ISO 8601 format, I used to modify the
ViewTemplate like this:
<span macro='view modified date [[YYYY-0MM-0DD 0hh:0mm]]'></span>
[...]
<span macro='view created date [[YYYY-0MM-0DD]]'></span>
Now the default date format has vanished from the shadow ViewTemplate.
While it is still possible to simply add the format just like before, I
wonder whether there is a variable now that I could modify instead (via
my DefaultOptions tiddler).
That strikes me as a "cleaner" method - even though I'd lose the ability
to have a different timestamp for the "created" field...
-- F.
<div class='subtitle'>
<span macro='view modifier link'></span>,
<span macro="hideWhen store.getValue('MonkeyGTDSettings','mgtd.usemdy')=='true'">
<span macro='view modified date [[DD/MM/YY]]'></span>
(<span macro='message views.wikified.createdPrompt'></span>
<span macro='view created date [[DD/MM/YY]]'></span>)
</span>
<span macro="showWhen store.getValue ('MonkeyGTDSettings','mgtd.usemdy')=='true'">
<span macro='view modified date [[MM/DD/YY]]'></span>
(<span macro='message views.wikified.createdPrompt'></span>
<span macro='view created date [[MM/DD/YY]]'></span>)
</span>
</div>
So you also add the date format directly to the ViewTemplate? Or am I
missing something here?
-- F.
Ohh, now I see! Sorry, I didn't look closely enough before...
> It would be much nicer to be able to enter the preferred format
> somewhere. (But please not a cookie, baked or otherwise. :).
Agreed.
I just took a quick look at the code, and there is something interesting
in "config.macros.view.handler": "config.views.wikified.dateFormat" is
used when no format has been specified in the ViewTemplate - but I'm not
sure whether (or how) that could be used for our purposes then...
-- F.
Um... forgive me, it was a long night last night and I haven't had my
requisite 1500ml of carbonated sodium benzoated caffeine yet this
morning, but am I missing something here? Don't you do this in your
regular MPTW layout?? I've taken that and modified it just a touch,
but it basically does what I think is being asked for here...
In a configTweak or equivalent:
// used in MptwViewTemplate
config.mptwDateFormat = 'DD/MM/YY';
config.mptwJournalFormat = 'Journal DD/MM/YY';
And then in the view template (the Mptw one in this case):
<span macro='view modified date {{config.mptwDateFormat?
config.mptwDateFormat:"MM/0DD/YY"}}'></span>
(<span macro='message views.wikified.createdPrompt'></span>
<span macro='view created date {{config.mptwDateFormat?
config.mptwDateFormat:"MM/0DD/YY"}}'></span>)
</div>
Using this technique, I have a number of different variations which I
control in one place (date formats, time formats, etc...).
Wouldn't this be what was originally asked for??
Well, I guess this is sort of what I'd asked for - but it feels like a
dirty hack somehow (Simon has acknowledged that himself).
So if we could go through "config.views.wikified.dateFormat" somehow,
that'd be a cleaner (and presumably easier) method...
-- F.
Well, then in that DefaultOptions tiddler (I call mine ConfigOverride,
but it's the same thing), could you not just override the value of
config.views.wikified.dateFormat to be what you wanted? There is also
config.macros.timeline.dateFormat that could be changed as well, to
use a different date format for the date "dividers" in the Timeline
tab.
Or add something like <<option txtDateFormat>> in the OptionsPanel,
and then refer to that (config.options.txtDateFormat) to override
config.views.wikified.dateFormat and
config.macros.timeline.dateFormat? (Or have a different option field
for the timeline format). I just tried that in a quick test and it
seemed to work okay.
Oh my - why didn't I just try that?! I somehow expected it not to work,
but it *does* indeed work! So now I'm using the following overrides:
config.views.wikified.dateFormat = "YYYY-0MM-0DD 0hh:0mm";
config.macros.timeline.dateFormat = "YYYY-0MM-0DD (ddd)";
No more need to touch the ViewTemplate for me...
Thanks, BJ!
One more thing: There's also an occurrence of dateFormat in connection
with listView; I'm not quite sure what the "ListView gadget" does
though; could anyone enlighten me?
-- F.
On Jun 28, 3:51 am, "Simon Baird" <simon.ba...@gmail.com> wrote:
> > > I do this kind of thing in MGTD alpha. It's not very nice though
>
>
> It would be much nicer to be able to enter the preferred format somewhere.
> (But please not a cookie, baked or otherwise. :).
>
In a configTweak or equivalent:
// used in MptwViewTemplate
config.mptwDateFormat = 'DD/MM/YY';
config.mptwJournalFormat = 'Journal DD/MM/YY';
And then in the view template (the Mptw one in this case):
<span macro='view modified date {{config.mptwDateFormat ?
config.mptwDateFormat:"MM/0DD/YY"}}'></span>
(<span macro='message views.wikified.createdPrompt'></span>
<span macro='view created date {{config.mptwDateFormat ?
config.mptwDateFormat:"MM/0DD/YY"}}'></span>)
</div>
Using this technique, I have a number of different variations which I
control in one place (date formats, time formats, etc...).
Wouldn't this be what was originally asked for??
<span macro='view created date [[DateFormat::shortDateFormat]]'></span>
> Wouldn't this be what was originally asked for??
Well, I guess this is sort of what I'd asked for - but it feels like a
dirty hack somehow (Simon has acknowledged that himself).
So if we could go through "config.views.wikified.dateFormat" somehow,
that'd be a cleaner (and presumably easier) method...
> could you not just override the value of
> config.views.wikified.dateFormat to be what you wanted? There is also
> config.macros.timeline.dateFormat that could be changed as well
Oh my - why didn't I just try that?! I somehow expected it not to work,
but it *does* indeed work! So now I'm using the following overrides:
config.views.wikified.dateFormat = "YYYY-0MM-0DD 0hh:0mm";
config.macros.timeline.dateFormat = "YYYY-0MM-0DD (ddd)";
No more need to touch the ViewTemplate for me...
Thanks, BJ!
That's brilliant!
More proof for the "TiddlyWiki makes you learn something new every day"
hypothesis...
N.B.: Make sure to use quotes in the DateFormat tiddler if the desired
format contains spaces.
In order to make this work for the timeline, use the following code in
your systemConfig tiddler (e.g. DefaultOptions or ConfigOverride):
config.macros.timeline.dateFormat =
store.getTiddlerSlice('DateFormat','shortDateFormat');
(I took that code from your solution in the "ColorPalette overview"
thread, Simon.)
N.B.: In this case, the date format must *not* be wrapped in quotes,
which is a bit of an annoying inconsistency.
That's one more reason to put this all into the systemConfig tiddler,
which is where it belongs anyway IMHO. But I don't know how to
distinguish between CREATED and MODIFIED dates then (I want both date
and time for MODIFIED, but only date for CREATED).
As for modifying variables in a systemConfig tiddler instead of
modifying the ViewTemplate:
> But then do you remove the format embedded in ViewTemplate??
Yes, because the default format (i.e. config.views.wikified.dateFormat)
is used if no dateFormat parameter has been specified.
> Now does anyone want to write the definitive guide to TW date
> formats for the doco wiki?
I'm not sure I could convey this in an understandable manner - I'll put
it on my to-do list though.
-- F.
On Jun 28, 8:21 pm, "Simon Baird" <simon.ba...@gmail.com> wrote:
>
> I didn't know these ones either. Nice one BJ. But then do you remove the
> format embedded in ViewTemplate??
Actually, the base TW's shadowed ViewTemplate tiddler doesn't have any
date format embedded in it... the calls to the view macro for the
dates are just <span macro='view created date'></span> (or 'view
modified date').
> Ps, The slice technique is still useful I think as it doesn't require a
> plugin to modify the format.
Yes, that is a pretty slick way to do it, although obviously it would
require the modifications to the view template to support it.
However, given that other things in the base TW use that approach
(i.e. ColorPalette), it might make sense if this is also done for date
formats and other configuration pieces. My concern is if it would be
as "error-resistant" as needed... what would happen if somebody has a
modified (non-shadow) tiddler with the different slices, but
accidently deletes one of the slices that are needed? With it defined
as a specific variable, there would always be that to fall back on.
On Jun 29, 6:09 am, FND <Ace_No...@gmx.net> wrote:
> > But here's an even better idea I just learned from BramChen:
> In order to make this work for the timeline, use the following code in
> your systemConfig tiddler (e.g. DefaultOptions or ConfigOverride):
> config.macros.timeline.dateFormat =
> store.getTiddlerSlice('DateFormat','shortDateFormat');
> (I took that code from your solution in the "ColorPalette overview"
> thread, Simon.)
Now THAT's interesting... and might address my concerns about being a
bit more "bullet-proof" -- perhaps using the conditional operator in
the equate to check to see if the tiddler slice can be obtained, and
leaving it alone or setting it to a default value if no slice is
returned.
Doing that same approach for config.views.wikified.dateFormat would
also eliminate the need to update the ViewTemplate code displaying the
created or modified dates, providing you wanted to use the same format
for both. I don't see why you couldn't create a different variable to
use for one of those cases, and then refer to it specifically in the
ViewTemplate where needed. I do something like that already to set
the date format used as the title for journal tiddlers.
>
> N.B.: In this case, the date format must *not* be wrapped in quotes,
> which is a bit of an annoying inconsistency.
>
I wonder if this relates to the comment in the base TW code (around
line 750) where the "translateable strings" are defined... it says
that strings in double quotes should be translated, strings in single
quotes will be left alone. Just a thought...
Let's see what JR and the devs think...
-- F.