date format and the $view widget

163 views
Skip to first unread message

Mohammad

unread,
Aug 1, 2019, 12:28:56 PM8/1/19
to tiddl...@googlegroups.com
In tiddlywiki.com create a tiddler with a field called yd

in the yd field enter the below value

20190801

and in the text filed enter the below script

<$view field="yd" format="date" template="mmm 0DD, YYYY" />

It will show the below result

Aug 01, 2019


Question

My question is how one can enter 2019-08-01 and get the same result?
Seems $view only work with a raw format of date.

I know there is a good macro developed by S.S to work with dates but I need a little simpler mechanism or a way to use the core feature!

--Mohammad

TonyM

unread,
Aug 1, 2019, 6:15:13 PM8/1/19
to TiddlyWiki
Mohammad,

With respect why?, I would keep the dates in system format and produce the output in the required format.

My Journal tiddlers put the date in a journal-date field for this very reason.

An approach, would be to use the new split operator on "-" then the set widgets select keyword to extract YYYY MM and DD values.

Regards
Tony


On Friday, August 2, 2019 at 2:28:56 AM UTC+10, Mohammad wrote:
In tiddlywiki.com create a tiddler with a filed called yd

in the yd filed enter the below value

Mark S.

unread,
Aug 1, 2019, 7:55:26 PM8/1/19
to TiddlyWiki
Here's an implementation of your suggestion (using pre 20)

<$set name="year" filter="[{!!yd}split[-]nth[1]]">
<$set name="mpos" filter="[{!!yd}split[-]nth[2]]">
<$set name="day" filter="[{!!yd}split[-]nth[3]]">
<$set name="month" filter="Jan Feb Mar Apr May June July Aug Sep Oct Nov Dec +[nth
<mpos>]">
<
<month>> <<day>>, <<year>>
</$set>
</$set>
</$set>
</$set>
<$text field="yd" format="date" template="mmm 0DD, YYYY" />


Mohammad

unread,
Aug 2, 2019, 1:59:36 AM8/2/19
to TiddlyWiki
Thanks Mark!
It works like a charm!

Cheers
Mohammad

Mohammad

unread,
Aug 2, 2019, 2:01:18 AM8/2/19
to TiddlyWiki
Tony!
 I am developing a timelines plugin and it uses a field to keep date and it is not the modified/created system field!
So I want user has the flexibility to enter date as 2019-03-01 or 20190301.

--Mohammad

Mohammad

unread,
Aug 2, 2019, 2:01:33 AM8/2/19
to TiddlyWiki
Added to TW-Scripts!


On Friday, August 2, 2019 at 4:25:26 AM UTC+4:30, Mark S. wrote:

TonyM

unread,
Aug 2, 2019, 2:16:26 AM8/2/19
to TiddlyWiki
Mohammad,

My suggestion is still valid the way you are using it. When it comes to date and time handling it is best to go back to the the most complete standard, one which caters for leading zeros, validation, international time zones and formatting via the tools built into tiddlywiki. Sure if the user only gives the yyyy mm dd save that ass yyyymmdd because it is still valid as the trailing zeros are assumed, but what time of day is a new day?, at 00:00am?

Have you looked at the pickaday plugin and other interactive date plugins?

Regards
Tony

Mohammad

unread,
Aug 2, 2019, 2:23:18 AM8/2/19
to TiddlyWiki
I did not get the point! I explain the case in more clear manner to see how I can use from your comment

    1. I am developing a timelines plugin
    1. The timelines plugin uses a field called date to create a horizontal or vertical flow of events
    2. The date field should have year, month and day of event
    3. The user will fill out the data field for example historical events of world wars two
    My problem here is user should have flexibility to fill out the date field! If I understand you advise to use a datepicker not manually fill out them!

    --Mohammad

    Mohammad

    unread,
    Aug 2, 2019, 2:37:49 AM8/2/19
    to TiddlyWiki
    Mark, 
    Based on your solution, there is no need to use the $view any more!


    On Friday, August 2, 2019 at 4:25:26 AM UTC+4:30, Mark S. wrote:

    Mohammad

    unread,
    Aug 2, 2019, 2:38:40 AM8/2/19
    to TiddlyWiki
    The last line also is not required

    <$text field="yd" format="date" template="mmm 0DD, YYYY" />



    On Friday, August 2, 2019 at 4:25:26 AM UTC+4:30, Mark S. wrote:

    TonyM

    unread,
    Aug 2, 2019, 9:05:35 AM8/2/19
    to TiddlyWiki
    Mohammad

    My key recommendation is store dates as tiddlywiki date fields then all the format options, opperators, search order and more remain available to you.

    If you want to allow manual entry of dates provide it, but store the result as a standard date field. If you always move to and from the standard you maintain the power the standard gives you like using the days operator, or using pickaday, or doing date comparisons or or or

    Choosing the format to store the dates as yyyy-0mm-0dd or yyyy/mm/dd or yyyymm is just departing from the standard. And all of the above are trivial to reproduce using the view widget.

    Regards
    Tony

    Mark S.

    unread,
    Aug 2, 2019, 12:15:38 PM8/2/19
    to TiddlyWiki
    That was just a paste-o.

    Mohammad

    unread,
    Aug 2, 2019, 12:33:14 PM8/2/19
    to TiddlyWiki
    Yep!
     It also does not use $view widget! :-)

    Cheers
    Mohammad
    Reply all
    Reply to author
    Forward
    0 new messages