Date format without $view ?

111 views
Skip to first unread message

Tony K

unread,
May 20, 2020, 12:54:48 PM5/20/20
to TiddlyWiki
is it possible to manipulate a timestamp without the $view?

I have timestamp saved in 2 formats 

old format 0hh:0mm and new format <<now "[UTC]YYYY0MM0DD0hh0mm0ssXXX">>

I am trying to make my code backward compatible so what I need is when I read the time stamp from the tiddler and display it in both cases as 0hh:0mm 

I tried to work with length 

\define long()
<$view tiddler=<<timestamp>> field=title format=date template="0hh:0mm" />
\end


<$list filter="""[<timestamp>length[]match[9]then<timestamp>else<long>]""" variable="type"/>

but in that case it is being evaluated to the full text and not the value :|

thanks in advance 

Saq Imtiaz

unread,
May 20, 2020, 1:00:57 PM5/20/20
to TiddlyWiki
Is <timestamp> a string with the timestamp, or a tiddler title? Perhaps post the entirety of your code as I don't quite understand what timestamp represents in each case.

Tony K

unread,
May 20, 2020, 1:07:32 PM5/20/20
to TiddlyWiki
it is a string but <$view tiddler=<<timestamp>> field=title format=date template="0hh:0mm" /> works in both cases

the code is very long it is at https://akhater.github.io/drift/ $:/ak/plugins/DailyNotes/ui/capture

Tony K

unread,
May 20, 2020, 4:46:14 PM5/20/20
to TiddlyWiki
Solved, I created a JS macro for it

thanks

TonyM

unread,
May 20, 2020, 7:58:57 PM5/20/20
to TiddlyWiki
Tony K,

Fine run with your solution with a JS macro since this is clearly your strength,However I am confident with a little more detail to your request, for clarity I can make a pure wikit text and widget solutions for you.

On the other hand using the title as a time stamp ie the primary key to a tiddler as an attribute (the time) of the tiddler is in my view not a good design choice. I have a much better one available. Just ask

Are you saying some tiddlers are named hhmm and others [UTC]YYYY0MM0DD0hh0mm0ssXXX ? and you want a function to handle them both equally?
  • We can do that with wikitext and widgets.
  • Why not make a batch operation to standardise the title in one go?
  • I would move the time stamp date to a separate field what ever you choose the title to be.
  • In tiddlywiki the title is both a unique key to its contents and often an aesthetic easy to read title.
Regards
Tony 

Tony K

unread,
May 21, 2020, 12:23:20 AM5/21/20
to tiddl...@googlegroups.com
Hello Tony

Thanks a lot for replying, and I would be highly interested to learn how to do it in wikitext and widgets

I tried to explain what I am trying to do in my OP but I will try again. Issue is it sounds so clear in my head that I am getting troubles explaining it.

Below are 2 entries in the same tiddler of my DailyNotes plugin. The first one has the old timestamp (only hours) the second one new timestamp

22:34~Entry with old time stamp <br />

20200520223405903~Entry with new time stamp  <br />

what I am trying to do is a function setting a variable called timestamp to 22:34 no matter if I feed it with  22:34 or 20200520223405903


regarding your point 
  • Why not make a batch operation to standardise the title in one go?
funny you should bring that up, I just wake up after a few hours of sleeping thinking about this but, still, I would like to know how to do the above for my own education 

 
thanks again 

TonyM

unread,
May 21, 2020, 2:10:51 AM5/21/20
to TiddlyWiki
Tony K

I imagine the reason you want to do it without the view widget is because it does not accept a variable as an input?, only tiddlers and fields. Something I have tried to get fixed because its out only built in date converter.

  • I have one possible solution which needs me to spit the longer timestamp into separate characters but the split[] operator does not do this. 
  • Here is another approach using maths operators, buit needs a little reworking for your own use.

\define timeonly(timestamp)
   
<$list filter="[[$timestamp$]length[]]" variable=length>
       
<$list filter="[<length>match[5]]" variable=nul>
             $timestamp$
<br>
       
</$list>
        <$list filter="[<length>match[17]]" variable=nul>
            {{{ [[$timestamp$]remainder[100000000]divide[1000000]trunc[]] }}}:{{{ [[$timestamp$]remainder[1000000]divide[10000]trunc[]] }}}<br>
        </
$list>
   
</$list>
\end
<$list filter="20200520223405903 23:45 22:21" variable=timestamp>
    <$macrocall $name=timeonly timestamp=<<timestamp>>/
>
</$list>


Regards
Tony

Mat

unread,
May 21, 2020, 7:16:18 AM5/21/20
to TiddlyWiki
TonyM wrote:
  • I have one possible solution which needs me to spit the longer timestamp into separate characters but the split[] operator does not do this. 
Sure it does

{{{ aabbcc +[split[]] }}}

<:-)

TonyM

unread,
May 21, 2020, 8:03:09 PM5/21/20
to TiddlyWiki
Mat,

Thanks, I thought that was so, yet it was just not working using this format below as well, but that now works as well

{{{ [[aabbcc]split[]] }}}

Clearly a glitch in the universe. Your stating the fact has put the universe back in place, thanks

Tony

TonyM

unread,
May 21, 2020, 8:22:15 PM5/21/20
to TiddlyWiki
Mat,/Tony K

I found when it breaks

{{{ [[$date$]split[]] }}}

In a macro with replaceable parameters, no split occurs.

Tony,

This issue with split is stopping me use the following on a variable (in a macro), rather than a fieldname to extract time of day 0hh:0mm without the view widget.

<$set name=1h filter="[{!!modified}split[]]" select=8>
<$set name=0h filter="[{!!modified}split[]]" select=9>
<$set name=1m filter="[{!!modified}split[]]" select=10>
<$set name=0m filter="[{!!modified}split[]]" select=11>
<<1h>><<0h>>:<<1m>><<0m>>
</$set></$set></$set></$set>


Regards
Tony


On Thursday, May 21, 2020 at 9:16:18 PM UTC+10, Mat wrote:
Reply all
Reply to author
Forward
0 new messages