Javascript Human Friendly Date Parser?

131 views
Skip to first unread message

amreus

unread,
Sep 12, 2020, 11:45:25 AM9/12/20
to TiddlyWiki

Ruby has this great library called Chronic that parses strings into Ruby Date objects. It handles date strings that are human friendly as well as in rigid formats.

You can see some usage examples here: https://github.com/mojombo/chronic

Has anyone already made such a parser for TiddyWiki5? Does anyone know if a similar library exists for Javascript which could be used?

Why?  I have a textbox for rapid list item entry.  Instead of picking a due-date for example, I just want to include the due-date as part of the text and have a macro parse it out from the title and add it as a date field. An example entry in my textbox might look like this:

Schedule a fire system test due:"oct 1 8am"

Saq Imtiaz

unread,
Sep 12, 2020, 1:19:32 PM9/12/20
to TiddlyWiki
Here is a list of JavaScript data parser libaries that I compiled a while back (so it may be out of date):
My use case was very similar to yours. Ultimately I wasn't happy with any of the existing options and rolled my own, which sadly isn't in a state to be shared any time soon.

Hope this helps,
Saq

amreus

unread,
Sep 12, 2020, 2:44:00 PM9/12/20
to TiddlyWiki
Saq,

Thanks for the list.  A better phrase would have been "natural language" date parser.

Dates in TiddlyWiki appear to be under-supported.  Would you agree, or am I missing something?  I know about the 3 Date filter operators.  But there seems to be a gap between the date storage format and the ability to enter dates in a convenient way. I have not even found a proper working date/time picker, which should come built-in imo. 

I don't even know where to start.  Do you have a github or anything I could browse for clues?

Thank you.

Saq Imtiaz

unread,
Sep 12, 2020, 3:20:55 PM9/12/20
to TiddlyWiki
Here is a datepicker plugin that you can use:

I would say that while greater support for dates as perhaps an official plugin would be welcome, natural language parsing of dates isn't a common enough use case to justify consideration for the core. The core is always a balancing act between utility and size.

My work on natural language date parsing isn't published anywhere online, and it's honestly too raw and incomplete to share. I was aiming to emulate the way Todoist.com handles dates and there is still some way to go.

amreus

unread,
Sep 12, 2020, 3:50:19 PM9/12/20
to TiddlyWiki
I've tried that date picker - it jumps back a day due after selecting the date. But not always.  From what I  gather it has to do with the timezone and TiddlyWiki dates being UTC.

PMario

unread,
Sep 12, 2020, 5:23:12 PM9/12/20
to TiddlyWiki
Hi,


-mario

PMario

unread,
Sep 12, 2020, 5:26:58 PM9/12/20
to TiddlyWiki
On Saturday, September 12, 2020 at 8:44:00 PM UTC+2, amreus wrote:

Thanks for the list.  A better phrase would have been "natural language" date parser.

That's interesting. How many "natural languages" does it support?

-m

amreus

unread,
Sep 12, 2020, 5:31:15 PM9/12/20
to tiddl...@googlegroups.com
I'm using a phrase that is used by some of the authors of the libraries. You'll have to ask them the question.

I added the phrase mostly to make the post relevant for search results.

amreus

unread,
Sep 12, 2020, 5:34:46 PM9/12/20
to TiddlyWiki
Thanks I'll read it.

TW Tones

unread,
Sep 12, 2020, 11:18:20 PM9/12/20
to TiddlyWiki
Re parsing an input;

There is a facility in the current pre release 

keyboard-driven-input Macro


This allows actions to be executed from an input field, say with enter. This may provide the opportunity to do post entry processing. Effectively allowing you to make more sophisticated parsing take place on a per input basis.

Thus you could pass the value to other functions, if available for the result.

Regards
Tony

amreus

unread,
Sep 15, 2020, 5:05:56 PM9/15/20
to TiddlyWiki
While trying to understand why dates are handled as they are in TIddyWiki, I found out it is not TiddlyWiki but Javascript that is the problem.

View this thread for some craziness (https://stackoverflow.com/a/31732581)

TW Tones

unread,
Sep 15, 2020, 7:44:17 PM9/15/20
to TiddlyWiki
Amreus,

In tiddlywiki, which can be opened by users in any timezone, it makes use of local time zone settings. As a result you need to learn to take account of UTC, I live at UTC +10 and Summertime +11 so I feel it.

I have not retested these following statements
  • if you generate a date with the now macro and other methods using the format "[UTC] rest of format" it will produce a date time stamp set at UTC/Greenwich mean time not the local time.
  • When displaying dates using UTC makes says it is a UTC and display with the local time zone added
In short tiddlywiki has support for international times zones, but you need to understand it to use it in some cases.

Regards
Tones
Reply all
Reply to author
Forward
0 new messages