Entering dates in fields

I am sure, I am NOT doing this in the TW way. So, let me ask.

I use fields like ‘due’, ‘published’ that contain date information, most often in YYYY-0MM-0DD format. These values are entered as clickable links — so, the field will carry value ‘[[2021-09-05]]’ but when transcluded, it will be a clickable link. This provides a quick access to the journal tiddler.

The way I enter these values is completely manual. I literally punch in those keys. Is there a better way of doing things? How?

There are a couple of date pickers…

http://kixam.github.io/TW5-datePicker/

https://quaraman.de/tw/datetimepicker.html#%24%3A%2Fplugins%2Fquaraman%2Fdatetimepicker

Hope that helps.

Please see the solutions mentioned in the following thread, but in particular my own date picker.

@Ste_W Thanks. The Date Picker is useful.

I am facing one problem. I want the field ‘due’ to carry the link to the date, not just the date. So, ‘due’ is set to ‘[[2021-09-06]]’. This is useful when I transclude it. I get a ready link to the journal tiddler.

So, I entered:

<$edit-date field="published-on" format="Do MMM YYYY" fieldFormat="[[YYYY-MM-DD]]"/>

in the tiddler. That did not work. I guess, I did not escape the [[ properly.

How do I do that?

@deshmukh
Try not to set the date field so that it is also a link, then you can’t use the date tools available to you. Create a way to turn the value in a field into a link when displaying it instead.

1 Like

G’day,

I was in need of a little coding exercise as brain-age game, and your post was perfect !

Just in case this is of any use to you, even if just for some fun inspection/giggles…

Put the following in a new tiddler:
(frigging narrow code box … requires a smidgen of scrolling right)

<$edit-text
    tiddler={{{ [<currentTiddler>addsuffix[ Data]] }}}
    field="this_value" type="date"/>

Getting the date back as a link:
{{{ [<currentTiddler>addsuffix[ Data]get[this_value]] }}}

Good times. Thanks !

1 Like

Stupid ADHD got the best of me.

Again, just for the coding giggles (if one doesn’t mind having to click on the button to pick a date, i.e. without the option of typing in the date):

<div style="position:relative;">
<div style="z-index:-1">
<$edit-text
    tiddler={{{ [<currentTiddler>addsuffix[ Data]] }}}
    field="this_value" type="date"/>
</div>

<div style="position: absolute;  left: 3px;  top: 2px;  z-index: 99;opacity:1;background-color:white;width:7em;">
<$text text={{{ [<currentTiddler>addsuffix[ Data]get[this_value]] }}}/>
</div>
</div>

Getting the date back as a link:
{{{ [<currentTiddler>addsuffix[ Data]get[this_value]] }}}
2 Likes

@TW_Tones Thanks. Got your point here. Will use date format in the date fields and other tools to display dates in preferred format.

Does your point apply to other fields, too? Like, say, ‘participants’? I set these values like these: ‘[[King George]] [[King Edward]] [[King Albert]]’. Does this have any disadvantages?

1 Like

@Charlie_Veniot Thanks. This works perfectly!

1 Like

@Charlie_Veniot But this did not work as expected. It just displays a box to enter with 2021-09-22 in it. And then the link to the same date. But I can not click on the box to change the date.

@deshmukh if you have only one value in a field there is no need to use the [[square brackets]] to delineate tiddlers, most widget attributes will handle values that have space in them unless it represents multiple tiddlers eg fieldname=“this is some text” is returned with {{!!fieldname}} or in filters [{!!fieldname}] [all[current]get[fieldname]] also if using fields a lot do look at the difference between has[fieldname] true if has a non blank value, has:field[fieldname]] true if fieldname exists, empty or otherwise.

If that field may however store a list, multiple titles such as the list field for tags (used behind the scenes) then it is common to use the square brackets eg [[square brackets]] nospace [[another tiddler]].

To handle such fields containing multiple titles there are a number of filter operators such as the listops list operators enlist and others to help adding, removing, sorting the titles in the list. These will put the [[square brackets]] when needed only and otherwise the titles are typically separated by a space.

nore do you whan a title does not contain spaces nospaces

2 Likes

You can’t click on the little box on the far-right side?

I posted two versions, which one are you using?

The first one was just the text edit widget, allowing direct edit of the date or click on the icon to pick a date.

The second one was a hack, the text edit widget covered partially by a view-only date, not allowing typing in the date and forcing click on the icon to pick a date.

1 Like

Arg. It could be a web browser or operating system limitation.

What kind of device, web browser, and operating system are you using?

I’m on a Chromebook, and it works A-1.

It tried it on linux using Firefox. It works very well.

@Charlie_Veniot OK. I tried it on a Linux computer Firefox browser. And yes, both the codes work. :slight_smile:

Thanks.

In part due to this thread I wrote my own date picker (again).

In this case the name provided will capture both the html format AND the tiddlywiki serial date. html-name-date and name-date. It has trhree features you may make use of;

  • Defaults to timestamp=no so the modified date on the tiddler does not change
  • Shows how to use the edit-text widget uses the inputActions parameter to ALSO save the serial date
  • by always using the name-date you could search for fields with the suffix[-date] to find all or any date field.
\define save-serial-date-actions() <$action-setfield $tiddler=<<tiddler>> $field=<<datename>> $value={{{ [all[current]get<html-date>split[-]join[]addsuffix[120000000]] }}} $timestamp="$timestamp$"/>
\define set-date(datename:"touch" tiddler timestamp:"no")
<$set name=datename value="$datename$-date">
<$set name=tiddler value="""$tiddler$""" emptyValue=<<currentTiddler>> >
<$set name=html-date filter="[<datename>addprefix[html-]]" >
<span title="set $datename$ date">
<$edit-text field=<<html-date>> type=date default=<<html-date>> inputActions=<<save-serial-date-actions>>/>
</span>
</$set></$set></$set>
\end

<<set-date>>

<<set-date journal>>

The default behaviour is to set the “touch” date or touch-date. This can be used to show you have visited an item but not modified it.

2 Likes